Code:
<class name="TestCompositeImpl"
table="test_composite" proxy="TestCompositeImpl">
<meta attribute="implement-equals">true</meta>
<composite-id class="TestCompositePK" >
<key-property name="id" column="DVC_ID" type="long" />
<key-property name="code" column="CMD_CODE" type="java.lang.String" length="10" />
</composite-id>
.....
TestCompositeImpl is the class that map the entire table, TestCompositePK is the class that map the key and is usefull for load object by key.
Code:
public class TestCompositePK implements Serializable{
Long id;
String code;
...
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result
+ ((code== null) ? 0 : code.hashCode());
return result;
}
public boolean equals(Object obj) {
...
}