-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: session.replicate and uninitialized hibernate collections
PostPosted: Fri May 14, 2004 1:09 am 
Newbie

Joined: Fri Jan 30, 2004 6:48 pm
Posts: 12
I seem to have found a problem with replicating objects that contain uninitialized Hibernate-typed collections. For example, if I load an object server-side and return it to my client and call replicate() on that object, I will get the following exception if the object contains some collections that were uninitialized by the server (lazy collections)

Code:
java.lang.NullPointerException
        at net.sf.hibernate.collection.Set.entries(Set.java:254)
        at net.sf.hibernate.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:512)
        at net.sf.hibernate.impl.ScheduledCollectionRecreate.execute(ScheduledCollectionRecreate.java:23)
        at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2407)
        at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2364)
        at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2229)
        at com.company.project.client.persistence.HibernatePersistenceFacade.storeObject(HibernatePersistenceFacade.java:221)
(etc)


looking at Hibernate's debug output, I see:
Code:
00:56:13,098 DEBUG [Printer] com.company.project.common.hibernate.User{password=casp, userName=casp, userId=483, roles=uninitialized, files=[], categories=[]}


If I explicitly set the uninitialized collection(s) to null, the problem goes away.

I can reproduce this behavior identically with both postgres and mckoi.

For some background on this post, please see:
http://forum.hibernate.org/viewtopic.php?t=930720

thanks for your help.
Justin[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 14, 2004 1:26 am 
Newbie

Joined: Fri Jan 30, 2004 6:48 pm
Posts: 12
looking at the hibernate code a bit, the problem happens when getting an iterator for the uninitialized Set. AbstractCollectionPersister.recreate should probably catch that NPE, but without knowing much about hibernate's codebase I'll leave that up to the experts.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.