From: Costantino C. (JIRA) <web...@jp...> - 2009-06-07 01:27:52
|
[ http://www.datanucleus.org/servlet/jira/browse/NUCDBFO-38?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16729#action_16729 ] Costantino Cerbo commented on NUCDBFO-38: ----------------------------------------- The solution of this issue is related to http://tracker.db4o.com/browse/COR-1670 > Lazy loading doesn't work on getter internally called by a persistence capable class. > ------------------------------------------------------------------------------------- > > Key: NUCDBFO-38 > URL: http://www.datanucleus.org/servlet/jira/browse/NUCDBFO-38 > Project: DataNucleus DB4O > Issue Type: Bug > Components: Persistence > Affects Versions: 1.1.0.release > Reporter: Costantino Cerbo > Attachments: testcase.zip > > > You want to persist a class with a collection, for example: > class Person { > ... > private Collection<Address> address = new LinkedHashSet<Address>(); > ... > } > The class Address use a getter in a method called by LinkedHashSet (in this case hashCode): > class Address { > ... > public int hashCode() { > return getId().intValue(); > } > ... > } > When you persist an instance of Person, whose Collection of Addresses had correctly set IDs, the following exception is thrown: > java.lang.NullPointerException > at org.datanucleus.store.db4o.Address.hashCode(Address.java:56) > at java.util.HashMap.put(HashMap.java:372) > at java.util.HashSet.add(HashSet.java:200) > at java.util.AbstractCollection.addAll(AbstractCollection.java:305) > at java.util.LinkedHashSet.<init>(LinkedHashSet.java:152) > at org.datanucleus.sco.simple.LinkedHashSet.initialise(LinkedHashSet.java:81) > The cause for this exception seems to be, that the lazy loading of the attributes doesn't happen when the method Address#getId() is invoked in Address#hashCode(). > Anyway this error occurs also when I tried to disable lazy loading with the property: > datanucleus.cache.collections.lazy=false -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://www.datanucleus.org/servlet/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |