View Single Post
  #2 (permalink)  
Old 05-31-2007, 04:44 PM
Marty Marty is offline
Member
 
Join Date: May 2007
Posts: 38
Marty is on a distinguished road
Hi nick
Code:
/** * @hibernate.class table="table" */ public class ClasswithCompositeId { private ClasswithCompositeIdPk PK; /** * @hibernate.id generator-class="assigned" * */ public ClasswithCompositeIdPk getPK() { return this.PK; } public void setPK(ClasswithCompositeIdPk thePK) { this.PK = thePK; return; } } package saes.election.eligibleoption; import java.io.Serializable; import org.apache.commons.lang.builder.*; public class ClasswithCompositeIdPk implements Serializable { /** * The composed eligible option this role is related to */ private Class1 key1; /** * The candidate this role is related to */ private Class2 key2; /** * @inheritDoc */ @Override public boolean equals(Object o) { } /** * @inheritDoc */ @Override public int hashCode() { } /** * @hibernate.many-to-one column="key1_code" outer-join="true" */ public Class1 getKey1() { return this.key1; } public void setCandidate(Class1 key1) { this.key1 = key1 ; } /** * @hibernate.many-to-one column="key2_code" outer-join="true" */ public Clase2 getClave2() { return this.key2; } public void setCandidate(Class2 key2 ) { this.key2 = key2 ; } } <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping > <class name="ClasswithCompositeIdPk " table="table" lazy="false" > <composite-id name="keyPK" class="ClasswithCompositeIdPk " > <key-many-to-one name="key1" class="Class1" column="class1_code" /> <key-many-to-one name="key2" class="Class2" column="class2_code" /> </composite-id> <!-- To add non XDoclet property mappings, create a file named hibernate-properties-RoleData.xml containing the additional properties and place it in your merge dir. --> </class> </hibernate-mapping>
good luck
Reply With Quote