I was trying to develop a custom Spring/Hibernate Converter to automatically bind form's checkboxes tag to Hibernate's persistent entities, when I discovered this bug.
Behind the scenes, Spring use reflection to discover the element type of a collection, in order to guess the right converter for the elements in it.
Unfortunately, when one read a persistent instance via Session.load() method, the type parameter informations are lost.
You can see the complete test in the it.unipg.jira.hibernate.Test class of the attached example. To run the tests, extract the archive and run
mvn -P hibernate3 clean tests
to test Hibernate 3 and
mvn -P hibernate4 clean tests
to test Hibernate 4.
BTW, consider the JPA entity below:
Consider now the following pseudo-java code:
As you can see, if we load() the persistent instance, the proxy javassist-generated class do not inherit the type parameters informations, so we cannot the collection's generic type.
I mark this Issue as Minor because one can effectively use get() instead of load() in most situations.
Sorry for my poor english.
Hibernate 3, Hibernate 4, Spring, Javassist, HSQLDB, OpenJDK6, Linux Debian stable
This bug report does not indicate that the reported issue affects version 5.x. Versions prior to 5.x are no longer maintained. It would be a great help to the Hibernate team and community for someone to verify that the reported issue still affects version 5.x. If so, please add the 5.x version that you verified with to the list of affected-versions and attach the (preferably SSCCE) test case you used to do the verification to the report; from there the issues will be looked at during our triage meetings.
For details, see http://in.relation.to/2015/10/27/great-jira-cleanup-2015/
As part of verifying that this issue affects 5.0, please just set the "Affects version". Leave the "verify-affects-5.0" label and leave the issue in "Awaiting Response" status; these are critical for us to be able to track these verifications and triage them. Thanks.
OK. Here attached is the new test case:
Uncompress the archive and launch the tests with Maven. There are three Maven profiles for the three versions of hibernate which I tested (3,4,5):
The class containing the two tests is it.unipg.jira.hibernate.Test
Thanks for verifying!
I am going to reclassify this. It is not a bug. You are asking for Hibernate something it never claimed to do. That is a feature/enhancement request, not a bug.