-->
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: equals and hashcode methods using hbm2java
PostPosted: Mon Oct 17, 2005 3:58 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
Hi,

we are using the latest release hibernate tools 3.1.0 a 5
and we are quite happy so far.
However there could be a slight improvement when generating
equals and hashcode methods.
For some reason we use a two step approach:

1. first generate the hbm-files with cfg2hbm
and edit them for some purposes.
2. generate the Java-Klasses and Id-Klasses.

Unfortunately in the second step the equals and hashcode-methods
are generated only when
Code:
<meta attribute="use-in-equals">true</meta>

is present in every primary key property.
Thats a lot of work.

However if we generate everything at once with
cf2hbm and hbm2java the equals and hashcode
methods are generated.
This leads me to the observation that there must be some
other way to tell hbm2java to generate the two methods.
For example a switch like:

Code:
<hbm2java generate-equals="true"/>


would be great!

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 17, 2005 4:48 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you should not use the id in equals methods - thus no easy way of doing this.

in the latest release though we generate equals/hashcode if you have <natural-id> defined.

_________________
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.