-->
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: Equals in different inheritance levels instances (same id)
PostPosted: Thu May 28, 2009 11:41 am 
Regular
Regular

Joined: Tue Feb 17, 2009 5:13 am
Posts: 59
Hi all.

I have a hierarchical model: B extends A.

Scenario:
Code:
A a = new A(id);
B b = new B(id);
//Notice a.id == b.id


The A.equals() method has been (eclipse)auto-generated involving only 'id' field.
I need a true value for a.equals(b).
The problem is in the line: this.getClass() != b.getClass().

An obvious solution would be to suppress that line in equals method, but I don't want to modify equals method because that sometimes raises problems when is used by Hibernate engine.

Any idea?

_________________
Born to lose... live to win!


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.