-->
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.  [ 2 posts ] 
Author Message
 Post subject: Equals Method
PostPosted: Fri Jan 16, 2004 10:22 am 
Newbie

Joined: Fri Jan 16, 2004 9:57 am
Posts: 1
Hi guys,

1st I want to thank all those particibated in the development of Hibernate. thanx for the good work

I created a hibernate mapping for an entity (group) that has a one-to-many relation to another (student) in a set (with cascade=all) and generated my java beans by hbm2java.
the problem is when i insert more than one new student the are getting replace by each other because they all have a null id i found the solution to add this two lines to the equals method

if( id == null )
return this == other;

now the problem is i need to add this each time i regenerate the beans java file ... and my entity relation model is not so small, so please help


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 10:31 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
equals and hashCode have been discussed here mutliple times allready, search the forum. If your change solves this for you, it should not be very difficult to adjust hbm2java to generate equals like that.


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