-->
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: HashCode function in Velocity Template to create POJOs ...
PostPosted: Thu Mar 17, 2005 11:28 am 
Regular
Regular

Joined: Fri Mar 04, 2005 1:33 pm
Posts: 65
Location: U.K.
Hi All,

I am using Velocity 1.4, HIbernate 2.1 and Midllegen 2.1. I have few tables with composite keys made up of primary keys of other tables. These table do not have either any other columns or they are not unique. Hibernate by default uses 'Set' structure in order to store collection in POJOs. The hashcode function I have in velocity template is unable to create unique code. I was wondering if anyone has a good Hashcode function defined? My code is as follows:

/** hashcode */
public int hashCode() {
HashCodeBuilder hcb = new HashCodeBuilder(17, 37)
#foreach($field in $clazz.getFields())
#if ( $field.getClassType().inJavaLang() || $field.getClassType().isPrimitive() || $field.getClassType().getPackageName().equals("java.math") || $javaTool.getTrueTypeName($field, $class2classmap).equals("java.util.Date") )

.append($field.getFieldName() )
#end
#end

;

return hcb.toHashCode();
}

Thank you
Ron


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.