-->
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: entity collection is not returning every element
PostPosted: Thu Mar 12, 2009 11:37 am 
Newbie

Joined: Tue Nov 25, 2008 2:24 pm
Posts: 2
I have a simple entity that connects to 4 other tables as a OneToMany relationship. When I fetch these collections, the correct number of results is returned. However, every object in the list is the same (the first object in the list). Furthermore, the objects are the exact same object reference.

Hibernate version:
Not sure what exact version. I believe its 3.1 (whatever comes with JBOSS 5.1

Mapping documents:
@OneToMany(fetch=FetchType.LAZY)
@JoinColumn(name = "person_nbr")
private List<Employment> positions;

@OneToMany(fetch=FetchType.LAZY)
@JoinColumn(name = "person_nbr")
private List<Email> emails;

@OneToMany(fetch=FetchType.LAZY)
@JoinColumn(name = "person_nbr")
private List<Role> roles;

@OneToMany(fetch=FetchType.LAZY)
@JoinColumn(name = "person_nbr")
private List<OtherId> otherids;


Name and version of the database you are using:
SQL SERVER 2005


I can post more debug stuff if you guys need, but not sure if any of it would help. (The sql looks fine and its pulling the data correctly just not all of it)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 12, 2009 4:12 pm 
Regular
Regular

Joined: Tue Dec 30, 2008 8:14 pm
Posts: 50
Make sure you have implemented hashCode and equals in Employment, Email, Role and OtherId; and the equals method checks key values.

LinHib.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 06, 2009 1:50 pm 
Beginner
Beginner

Joined: Sat Jul 08, 2006 2:58 pm
Posts: 26
Did implementing hashcode and equals fix this problem? I'm running into the same problem.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 07, 2009 5:25 am 
Regular
Regular

Joined: Thu Sep 06, 2007 2:22 am
Posts: 108
Location: Noida,India
Quote:
However, every object in the list is the same (the first object in the list). Furthermore, the objects are the exact same object reference.


Have you check the id (Database id) of every object?


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.