You can get this information, as shown below, but I'm not sure that I will do this in production code if I really do not need the names of the tables that can be changed after compiling the code. Otherwise, is it really worth the read value for your code?
AbstractEntityPersister metadata =
(AbstractEntityPersister) sessionFactory.getClassMetadata(User.class);
String tableName = metadata.getTableName();
String[] columnNames = metadata.getKeyColumnNames();
source
share