Using Hibernate 3.5..
I am seeing an issue when using standard hibernate sessions that after doing a load() the proxied class loses all information about declared annotations..
For example..
Code:
User customer1 = (User) HibernateUtil.getCurrentSession().load(User.class, id);
Class class1 = customer1.getClass();
class1.getDeclaredAnnotations().length //always 0
However if you use the EntityManager
Code:
EntityManager em = getEMF().createEntityManager();
EntityTransaction tx = em.getTransaction();
User customer2 = em.find(User.class, id);
Class class2 = customer2.getClass();
class2.getDeclaredAnnotations().length //has visibility to correct annotations
this seems to be the case regardless if you use javassist or clib as your bytecode provider
I cant imagine this is intended behavior. It becomes particularly problematic when working with other packages which use or expect annotations. An entity object looked up via hibernate session is now unusable if any downstream processing needs to use annotations provided on the entity class. I am having particular issues with RestEasy , but i imagine this would be a problem with just about any Jaxb marshaling which is expecting class annotations..
I realize i may have to make the final switch over to EntityManager, but thats not the point. Am I missing something or has this always been a problem with Hibernate?
thanks