This is my first try with Composit keys. I am workoing with a legacy database and for this table, the fields OBDATE, OBKEYNBR, and OBSEQ make up a unque key.
When I loop through the list, every item has the same data? It is always the first item in the record set. Am I missing something?
My hbm.xml file...
<class name="com.sys.dao.LabobrBean" table="LABOBR">
<composite-id name="labobrKey" class="com.sys.dao.LabobrComposite">
<key-property name="labTestDate" column="OBDATE"/>
<key-property name="seqNo" column="OBKEYNBR"/>
<key-property name="resultsProcessingSeqNo" column="OBSEQ"/>
</composite-id>
... other mappings ....
My composite class.
public class LabobrComposite implements java.io.Serializable {
private String labobrKey = null;
private Integer labTestDate = null;
private Integer seqNo = null;
private Integer resultsProcessingSeqNo = null;
public String getLabobrKey() {
return (this.labobrKey);
}
public void setLabobrKey(String labobrKey) {
this.labobrKey = labobrKey;
}
public Integer getLabTestDate() {
return (this.labTestDate);
}
public void setLabTestDate(Integer labTestDate) {
this.labTestDate = labTestDate;
}
public Integer getSeqNo() {
return (this.seqNo);
}
public void setSeqNo(Integer seqNo) {
this.seqNo = seqNo;
}
public Integer getResultsProcessingSeqNo() {
return (this.resultsProcessingSeqNo);
}
public void setResultsProcessingSeqNo(Integer resultsProcessingSeqNo) {
this.resultsProcessingSeqNo = resultsProcessingSeqNo;
}
public boolean equals(Object other){
if(!(other instanceof LabobrComposite)) return false;
LabobrComposite castOther = (LabobrComposite) other;
return new EqualsBuilder().append(this.getLabobrKey(),
castOther.getLabobrKey()).isEquals();
}
public int hashCode(){
return new HashCodeBuilder().append(getLabobrKey()).toHashCode();
}
}
When I look at the log, it shows that two rows have been returned (sorry can not show you. It contains patient data). However, the list has the same data for each row.
Any help?
|