| A slight variant to my prior answer, as this code exists on both releases as-is:
final SessionFactoryImplementor sessionFactory = session.getFactory().unwrap( SessionFactoryImplementor.class );
final EntityPersister persister = sessionFactory.locateEntityPersister( SomeEntity.class );
final String qualifiedName = persister.getEntityName();
While this method is deprecated in 5.2, it does exist in 5.1 allowing you to use a single code path without any reflection. As a heads up, I would expect these deprecated methods being removed in 6.0. |