-->
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: Help needed
PostPosted: Mon Mar 16, 2009 3:08 pm 
Newbie

Joined: Mon Mar 16, 2009 3:00 pm
Posts: 1
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.

Any help will be appreciated.

Thanks

_________________
cars
colleges


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 19, 2009 9:51 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you can adjust the templates to do your custom equals/hashcode implementation.

But got and read http://www.hibernate.org/109.html before.
Your equals implementation is not a equals/hashcode that will behave correct when used within collections.

_________________
Max
Don't forget to rate


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.