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
2009-10-22 07:46:59