From: Andrey M. (JIRA) <no...@at...> - 2006-05-25 14:05:14
|
hbm2java does not generate equals/hashCode for composite-id ----------------------------------------------------------- Key: HBX-667 URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-667 Project: Hibernate Tools Type: Bug Components: hbm2java, ant Versions: 3.1.beta5 Environment: Hibernate 3.1.3, Sybase database, Windows platform Reporter: Andrey Myatlyuk Attachments: library_dir.gif I'm using Hibernate Tools 3.1.0.beta5 If I use the tools as plug-in for eclipse, it works perfect. All hashCode and equals methods are generated automatically. But if I use Ant task to do the same, no hashCode or equals method are generated. If I use meta attibutes in mapping, then method is implemented, but I have too many composite id to generate, so I'd like hbm2java generate them for me. As it suppose to do. hibernate.cfg.xml and mappings are the same the list of jar files is attached Ant build script: <path id="library.hibernatetools.classpath"> <fileset dir="C:/dev/hibernate/hibernatetools-3.1.0.beta5/lib"> <include name="*.jar"/> </fileset> </path> <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="library.hibernatetools.classpath"/> <target name="hbm2java"> <hibernatetool destdir="${module.jstl.basedir}/src"> <classpath> <path location="${module.jstl.basedir}/src"/> </classpath> <configuration configurationfile="${module.jstl.basedir}/src/hibernate.cfg.xml"/> <hbm2java/> </hibernatetool> </target> Mapping: <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- Generated May 22, 2006 3:18:01 PM by Hibernate Tools 3.1.0.beta5 --> <hibernate-mapping> <class name="model.ResponseNote" table="ECB_NOTES_RESP" schema="dbo" catalog="recon_dev"> <composite-id name="id" class="model.ResponseNoteId"> <key-property name="ecbResponseId" type="long"> <column name="ECB_RESPONSE_ID" precision="15" scale="0" /> </key-property> <key-property name="ecbEligibilityId" type="int"> <column name="ECB_ELIGIBILITY_ID" /> </key-property> <key-property name="ecbNotesId" type="int"> <column name="ECB_NOTES_ID" /> </key-property> </composite-id> <property name="notes" type="string"> <column name="NOTES" length="264" /> </property> </class> </hibernate-mapping> Generated java with Ant task: package model; // Generated May 24, 2006 2:51:40 PM by Hibernate Tools 3.1.0.beta5 /** * ResponseNoteId generated by hbm2java */ public class ResponseNoteId implements java.io.Serializable { // Fields private long ecbResponseId; private int ecbEligibilityId; private int ecbNotesId; // Constructors /** default constructor */ public ResponseNoteId() { } /** full constructor */ public ResponseNoteId(long ecbResponseId, int ecbEligibilityId, int ecbNotesId) { this.ecbResponseId = ecbResponseId; this.ecbEligibilityId = ecbEligibilityId; this.ecbNotesId = ecbNotesId; } // Property accessors public long getEcbResponseId() { return this.ecbResponseId; } public void setEcbResponseId(long ecbResponseId) { this.ecbResponseId = ecbResponseId; } public int getEcbEligibilityId() { return this.ecbEligibilityId; } public void setEcbEligibilityId(int ecbEligibilityId) { this.ecbEligibilityId = ecbEligibilityId; } public int getEcbNotesId() { return this.ecbNotesId; } public void setEcbNotesId(int ecbNotesId) { this.ecbNotesId = ecbNotesId; } } Generated java within Eclipse: package model; // Generated May 24, 2006 11:43:19 AM by Hibernate Tools 3.1.0.beta5 /** * EcbNotesRespId generated by hbm2java */ public class EcbNotesRespId implements java.io.Serializable { // Fields private long ecbResponseId; private int ecbEligibilityId; private int ecbNotesId; // Constructors /** default constructor */ public EcbNotesRespId() { } /** full constructor */ public EcbNotesRespId(long ecbResponseId, int ecbEligibilityId, int ecbNotesId) { this.ecbResponseId = ecbResponseId; this.ecbEligibilityId = ecbEligibilityId; this.ecbNotesId = ecbNotesId; } // Property accessors public long getEcbResponseId() { return this.ecbResponseId; } public void setEcbResponseId(long ecbResponseId) { this.ecbResponseId = ecbResponseId; } public int getEcbEligibilityId() { return this.ecbEligibilityId; } public void setEcbEligibilityId(int ecbEligibilityId) { this.ecbEligibilityId = ecbEligibilityId; } public int getEcbNotesId() { return this.ecbNotesId; } public void setEcbNotesId(int ecbNotesId) { this.ecbNotesId = ecbNotesId; } public boolean equals(Object other) { if ((this == other)) return true; if ((other == null)) return false; if (!(other instanceof EcbNotesRespId)) return false; EcbNotesRespId castOther = (EcbNotesRespId) other; return (this.getEcbResponseId() == castOther.getEcbResponseId()) && (this.getEcbEligibilityId() == castOther .getEcbEligibilityId()) && (this.getEcbNotesId() == castOther.getEcbNotesId()); } public int hashCode() { int result = 17; result = 37 * result + (int) this.getEcbResponseId(); result = 37 * result + this.getEcbEligibilityId(); result = 37 * result + this.getEcbNotesId(); return result; } } With all this code with Ant task I get ResponseNoteId java file without equals or hashCode methods. While within Eclipse, using the same code I get equals and hashCode implemented. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |