-->
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.  [ 5 posts ] 
Author Message
 Post subject: When does hibernate return a proxy?
PostPosted: Wed Oct 05, 2005 4:57 pm 
Regular
Regular

Joined: Tue Mar 01, 2005 2:35 pm
Posts: 60
I used to always asume that calling Session.load() would give me a proxy (or bytecode enhanced) object, but now I'm not sure if that's the case. It looks like now when I call load, I get an object with it's collections set to null, giving me null pointers when I try access them. What is the documented behavoir here?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 5:28 pm 
Regular
Regular

Joined: Thu Jul 29, 2004 11:55 pm
Posts: 75
There is not enough information, but I will take my best guess at what is happening. If your pojo doesn't initialize the collections in the default constructor, then they are null by default. If your collection is empty, hibernate will not set the collection, so it remains null. So, I would try initializing empty collections on object construction and see if that solves your problem.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 6:40 pm 
Regular
Regular

Joined: Tue Mar 01, 2005 2:35 pm
Posts: 60
Hmm, I guess I just assumed that Hibernate would give me an empty collections. Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 06, 2005 4:23 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Yes, Hibernate always returns empty collections, never nulls, when it instantates the object.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 06, 2005 11:02 am 
Regular
Regular

Joined: Tue Mar 01, 2005 2:35 pm
Posts: 60
So am I right to assume that this should never be true?

session.load(o.class, id).getMappedCollection() == null

Because that's what's happening. I'm using the latest betas of Hibernate 3.1 and the annotations.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.