aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate 3 Not Loading Values Into Child Set In JUnit Test Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate 3 Not Loading Values Into Child Set In JUnit Test" Watch "Hibernate 3 Not Loading Values Into Child Set In JUnit Test" New topic
Author

Hibernate 3 Not Loading Values Into Child Set In JUnit Test

Michael Duffy
Ranch Hand

Joined: Oct 15, 2005
Posts: 163
I"m trying to use Hibernate 3 with Spring. I've got two classes with a unidirectional parent-child relationship: QuestionnaireResponse and Answer. A QuestionnaireResponse has a child Set of Answers. I've attached the Hibernate mapping below (just to keep the narrative together).

Of course I'm writing JUnit tests. I've got a test where I query for a particular QuestionnaireResponse and check the result I get back. The query is returning the right response for a given individual, but when I check to see if the associated answers are included I find that the Set size is zero instead of the 24 I expected from the database values.

I've set it up so I'm using eager loading. What did I miss with Hibernate? Why is it not getting the assocated Answers in this simple 1:m relationship? Thanks.

QuestionnaireResponse.hbm.xml



%
Chris OConnell
Greenhorn

Joined: Jan 26, 2006
Posts: 1
I'm having the same sort of problem. However, I have a relationship that 'sometimes' load and sometimes doesn't. Anyone else seen this sort of behavior?


Chris
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate 3 Not Loading Values Into Child Set In JUnit Test