-->
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.  [ 3 posts ] 
Author Message
 Post subject: hashCode & isEqual with same session different transacti
PostPosted: Wed Jan 11, 2006 10:16 am 
Beginner
Beginner

Joined: Thu Sep 22, 2005 7:22 am
Posts: 21
Hibernate version: 3.1

if I use different transactions when retreiving different objects, and now when I try to remove an item from a Set it doesn`t get removed... before when everything was under the same transaction this was working.
I remember reading that if the objects where retreived using the same session hashCode() and isEqual() doesn`t need to be overridden.

_________________
/ted


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 10:38 am 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
I do not think that this is an issue of hashCode or equal.
may be your object is resaved as you have not properly removed it.
eg. bidrectional many to one
A.getBs().remove(A)
B.setA(null)
session.remove(B);

If this is not hte case you should post your complete code and mappings.
Sebastian

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 11:14 am 
Beginner
Beginner

Joined: Thu Sep 22, 2005 7:22 am
Posts: 21
LaLiLuna wrote:
I do not think that this is an issue of hashCode or equal.
may be your object is resaved as you have not properly removed it.
eg. bidrectional many to one
A.getBs().remove(A)
B.setA(null)
session.remove(B);

If this is not hte case you should post your complete code and mappings.
Sebastian


I mean that the object is not removed from the Set because they are two different objects (in the JVM) I am doing session.remove(b) and it gets deleted from the db. but when I do A.getBs().remove(A) it doesn`t get removed because of hashCode and isEqual()

when the A and the B is retreived under the same transaction this works.

but it should suffice to retreive them under the same session, as far as I remember.
or am I wrong?

_________________
/ted


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