-->
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.  [ 4 posts ] 
Author Message
 Post subject: hbm2java question
PostPosted: Tue May 30, 2006 3:18 am 
Beginner
Beginner

Joined: Sat May 20, 2006 3:40 pm
Posts: 21
Was reading about this, and am just was wondering how the following situation might work:

You have hbm files that you'll generate java files from with hbm2java, then you'll override equals() and hashCode() (and make any other additions to the generated java files), then you'll continue your build process...

Is it possible to automate the above in Ant?

You could of course put the hbm2java in Ant, but in between every build would you have to manually go into the generated java files, modify them accordingly, then continue the build (e.g. compilation, packaging, etc...)?

Perhaps I've misunderstood the use or intention of hbm2java...any clarification would be appreciated.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 30, 2006 5:48 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
<meta attribute="use-in-equals">true</meta>

for generating equals/hashcode.

and

<meta attribute="generated-class">BaseCustomer</meta> to auto create a BaseCustomer you then extends if you want to add additonal code.

(we also have an "extra-code" meta attribute but that is not recommende unless really needed)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 08, 2006 4:20 pm 
Beginner
Beginner

Joined: Sat May 20, 2006 3:40 pm
Posts: 21
When using use-in-equals and use-in-tostring, how come it doesn't use the Jakarta Commons classes:

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

I saw an example from Hibernate 2 where (for some reason without even having use-in-equals and use-in-tostring in the mapping file), the above imports were generated and those classes were used in the generation of equals(), hashCode(), and toString().

Was this changed to not use the Commons classes in Hibernate 3, or am I missing something here?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 09, 2006 2:48 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i updated the tools migration guide about this, but in short the answer is: The genereted code should not have a dependency on otherwise unnedded libraries.

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