-->
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: Hibernate equals() and hashCode() not called
PostPosted: Thu Aug 12, 2010 8:15 pm 
Newbie

Joined: Thu Aug 12, 2010 2:34 pm
Posts: 1
dear all,

i am using Hibernate 3.5.4 final with Annotations Configuration
although I implemented the methods equals() and hashCode()
in the persistence classes they are not called by hibernate.
I inserted some print-outs, but nothing is written on console. Also
when putting breakpoints, they are never reached.

The classes are using the annotations:
------------------------------------------------------
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
------------------------------------------------------

and several OneToOne-Realations defined like:
---------------------------------
@OneToOne(cascade = CascadeType.ALL,fetch = FetchType.LAZY)
private Property property;
---------------------------------

What could i do that hibernate uses equals and hashCode methods?
Is there anything i should configure in the hibernate.cfg.xml file?

thanking you very much in advance for your help

best regards Malcom


Top
 Profile  
 
 Post subject: Re: Hibernate equals() and hashCode() not called
PostPosted: Fri Aug 13, 2010 1:21 am 
Regular
Regular

Joined: Fri Aug 06, 2010 1:49 am
Posts: 102
Location: shynate26@gmail.com
Hi Malcome,

If the entity in persisted state, hibernate makes use of the equals & hashcode method and it checks the equality of the natural key present in database rather than checking all the properties. This is one of the feature hibernate does by its own.

_________________

Cheers!
Shynate
mailto:shynate26@gmail.com
www.CSSCORP.com


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.