-->
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.  [ 1 post ] 
Author Message
 Post subject: Bidirectional one-to-many with an indexed collection
PostPosted: Fri Aug 13, 2004 10:56 am 
Newbie

Joined: Thu Aug 12, 2004 5:30 am
Posts: 2
I've been following the documentation here:

http://www.hibernate.org/193.html

and have a question:

If I add objects that contain identical values to a List and persist them, they correctly appear in the database with an ID of 0 and 1, and an index_col of 0 and 1.

i.e.
Code:
ID   Name  ParentId  Index_col
0     foo      0            0
1     foo      0            1
2     foo      1            0
3     foo      1            1


If I override the Equals method, to compare just for business equality, (i.e. not comparing the ID) then the following code fails:

public int getIndex()
{
return this.getParent().getChildren().indexOf(this);
}

as the first item in the List will always be returned.

For Bidirectional one-to-many relationships with an indexed collection should I NOT override the Equals method?


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

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.