2009年4月17日星期五

Getting the table name of the mapped entity

1. Convert the session into EventSource (see SessionImpl)
2. Get the persister and convert the persister into AbstractEntityPersister
3. There is a getTableName method in AbstractEntityPersister, but not in the EntityPersister interface.

EventSource source = (EventSource)getSession();
EntityPersister persister = source.getPersistenceContext().getEntry(entity).getPersister();
String tableName = ((AbstractEntityPersister)persister).getTableName()

沒有留言: