-->
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: How to generating compareTo() method?
PostPosted: Wed Nov 30, 2005 4:12 pm 
Beginner
Beginner

Joined: Tue Nov 15, 2005 6:56 pm
Posts: 39
Using latest compilation from CVS of hibernate-tools3.0.1-beta1

I'm trying to generate the toCompare() method for my generated classes. I'm thinking of writing my own custom velocity template to do this.

I'm looking at the PojoEqualsHashcode.vm as en example. In that template, I see that a method called "needsEqualsHashCode()" is called on the pojo. Is there an equivalent somewhere for checking to see if it needs compareTo method? Or maybe I'm going down the wrong path on this one?

If anyone has a better way to do this, please let me know.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 30, 2005 5:24 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you are on the right path.

you will just need to define a meta attribute that ideintifies wether a compareto is needed.

if you add this then provide a patch and i'll integrate it.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: How to generating compareTo() method?
PostPosted: Thu Jun 13, 2013 11:19 am 
Newbie

Joined: Thu Jun 13, 2013 11:05 am
Posts: 1
This is a post from 2005. Does anyone know if this problem was solved?

If we create a compareTo method in one of our Hibernate domain model objects and then Use Hibernate Tools to regenerate the model, the compareTo is erased.

Is there any way to keep certain methods in an exisiting domain model object when using Hibernate Tools?


Top
 Profile  
 
 Post subject: Re: How to generating compareTo() method?
PostPosted: Mon Jun 17, 2013 7:26 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
compareTo support was never contributed no.

I've always wanted to add support for jmerge into hibernatetools to allow retaining code between generations but have not happened - it would be *really* interesting though. hint-hint ;)

One way to add extra code via hbm.xml approach is to use meta attributes like:

Code:
<meta attribute="class-code">public int compareTo(Object other) { .... }</meta>


Whatever is listed in class-code gets added to the end of the generated class.

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