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
|