-->
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.  [ 4 posts ] 
Author Message
 Post subject: NullPointerException returned instead of PersistentSet
PostPosted: Fri Aug 12, 2005 8:46 pm 
Newbie

Joined: Tue May 10, 2005 1:16 pm
Posts: 16
Location: Vancouver, BC, Canada
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0.5

Name and version of the database you are using: MySQL 4.1


I have a parent-child relationship.

Both parent and child are actually the same class (but I think this is irrelevant).

The class as (a few) collections.

Occasionally (and hence the debuggin problem) if I load a persisted instance all the collections it has return null. They should return PersistentSets as I have lazy="true".

If I change to lazy="false" (on the class) I don't get the nulls. My instance is correctly 'hydrated'.

I believe this happens when I load a child, then getParent().getMyCollection().

I have tried today to put together an isolated test case, which leads me to be able to reproduce the error simply by turning on and off the lazy initialization. Unfortunately, I'm not sure what to put in the senario for my test case, as the problem doesn't always appear - but in a given situation is repeatable.

Seeing as I have given a very hazy explaination, and can't produce a good test case, I would just like to know if this 'rings any bells' as to what might be going wrong.

For now, I will have to set lazy="false" and continue development...

Thanks.

_________________
http://www.JamesAshepherd.com/


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 12, 2005 9:58 pm 
Beginner
Beginner

Joined: Thu Mar 31, 2005 9:58 pm
Posts: 25
Location: Valparaiso
Change the fetch strategy only for that parent-child relationship, not to the entire model. With annotations is very easy, in the parent side you have to put a @Column with the fetchtype setted EAGER. For more details, check the specification of EJB3 persistence (java.sun.com)

_________________
Daniel Casanueva R.

Jcode
Valparaiso, Chile


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 4:29 pm 
Newbie

Joined: Tue May 10, 2005 1:16 pm
Posts: 16
Location: Vancouver, BC, Canada
I tried setting outer-join="true" on the getParent() property (many-to-one), and I still get NullPointerException. I believe this is equivalent to eager fetch, but I might be wrong.

I tried lazy="false" on the many-to-one and I have a working program again. I don't know if this is equvalent to putting lazy="false" on the class referenced. It is definately something to do with the collection references not being initialized.

Anyhoo, thanks for the help.

The only other thing similar to this is [url=http://opensource.atlassian.com/projects/hibernate/browse/HHH-825], but I tried 3.1Beta1 and still got a NullPointerException.

_________________
http://www.JamesAshepherd.com/


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 4:47 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
It is of course impossible for anyone to help you given that you have shown neither mappings, classes, code or HB log.


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