|
http://stackoverflow.com/questions/15133569/empty-collection-being-returned-by-classmetadata-getpropertyvalueinitializedpro
I have an entity A which has a Lazy List. I load a proxy of A, and initialize it. I get sessionFactory.getClassMetadata(A.class). I use this metadata to load the list property on the initialized proxy of A. The list property is mappedBy the @ManyToOne on B, and there are values of B which point to that particular instance of A.
The result of getPropertyValue is an empty collection. Trying to initialize it via Hibernate.initialize does nothing.
Assuming you have all necessary dependencies in your classpath (Spring, HSQLDB etc), the attached files should provide a failing JUnit test for this problem.
Interesting fact: If I remove the initialization of the variable items in Composition, I'll have a NullPointerException instead of an AssertionError at the last line of the test. It seems the mappedBy is not being taken into account.
|