-->
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: Equality for java object in entitymanager transaction
PostPosted: Fri Jul 06, 2012 2:59 am 
Newbie

Joined: Fri Jul 06, 2012 2:55 am
Posts: 1
I have two objects (A e B) from the same class that are different in values (different attribute values ) but when i find B object (em.find(primary embedded key of B)) it return A. (A e B are two different object - different value for all attributes)

Example 1: (A e B are two different object - different value for all attributes)

EntityTransaction tx = em.getTransaction();
tx.begin();
em.merge(A);
Object o = em.find(B); // <<--- O EQUALS A ?!?!?!?!

Example 2:

EntityTransaction tx = em.getTransaction();
tx.begin();
em.merge(A);
Object o = em.merge(B); // <<--- O EQUALS A ?!?!?!?!

Example 3:

EntityTransaction tx = em.getTransaction();
tx.begin();
em.merge(A);
tx.commit();
tx.begin();
Object o = em.merge(B); // <<--IT IS CORRECT!!! O EQUALS B

Hashcode and equals methods are correct. My question is: What's the method for comparison of A and B in context of single transaction? (Hashcode and equals are not used!!!)
I use a composite key of three objects. (primary key is @EmbeddedId object). Every single objects have hashcode and equals methods implemented.
Hibernate versions are: hibernate-entitymanager-3.5.0-Final.jar, hibernate-jpa-2.0-api-1.0.0.Final.jar, hibernate3.jar
Thanks in advance


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.