How to get the table name from a `DataObject`?

39 Views Asked by At

A table my_table should have a generated class named MyTable. How do I get the table name, my_table, from Cayenne while having access to MyTable?

I'm not looking for snake_case <=> CamelCase that kind of approach. I'm looking for something like MyTable.TABLE_NAME (not exists) or Cayenne.getTableName(MyTable.class) (not exists either).

(using Cayenne 4.2.RC2)

1

There are 1 best solutions below

0
On

You can get it from Cayenne metadata:

String tableName = objectContext
  .getEntityResolver()
  .getObjEntity(MyTable.class)
  .getDbEntityName();