tags:

views:

65

answers:

1

I have an Object. How can I know if its class is mapped to a table in Hibernate?

+4  A: 

EDIT: My original answer works but will initialise unitialised proxies, which may be undesirable.

Better solution

boolean isHibernateEntity = sessionFactory.getClassMetadata( HibernateProxyHelper.getClassWithoutInitializingProxy( yourObject ) ) != null;

Original answer:

boolean isHibernateEntity = sessionFactory.getClassMetdata( Hibernate.getClass( yourObject ) ) != null;
Mike Q