Hi
I am using Hibernate 2.1, Middlegen 2.1 with Oracle 9i. I have a link table which only has a composite key made up of 3 primary keys. This link table does not have any other columns.
I am also using Velocity template to generate POJOs. The problem I am facing has to do with hash code generated for two rows of this link table. The hashcode comes out to be exactly same as a result I get only one row back from this table. Following is a code for Hashcode generation:
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();
}
As this link table doe snot have any other columns, nothing gets appended and hashcode is same all the time. Has anyone come across this and built their own better version of hashcode ?
Thanks a lot.
Ron
|