帮忙看下,高分结贴,急急急。。。。
用SSH作的系统,有张表用的是复合主键,帮忙看下在.hbm.xml配置文件中这样配置复合主键对吗?
<hibernate-mapping>
<class name="com.tzl.entity.Debit" table="debit" catalog="PARKINFO-PLATFORM">
<composite-id name="id" class="com.tzl.entity.DebitId">
<key-property name="devId" type="java.lang.Integer">
<column name="dev_id" />
</key-property>
<key-property name="outTime" type="java.sql.Timestamp">
<column name="out_time" length="19" />
</key-property>
</composite-id>
这个是实体类,主键单独是一个类,如下:
public class Debit implements java.io.Serializable {
private DebitId id;
private Integer cardUid;
private Float cash;
private Float paidIn;
private Float balance;
private Timestamp inTime;
private Integer cardStatus;
private Integer tag;
private Integer devIdIncar;
public Debit() {
}
public Debit(DebitId id) {
this.id = id;
}
public Debit(DebitId id, Integer cardUid, Float cash, Float paidIn,
Float balance, Timestamp inTime, Integer cardStatus, Integer tag,
Integer devIdIncar) {
this.id = id;
this.cardUid = cardUid;
this.cash = cash;
this.paidIn = paidIn;
this.balance = balance;
this.inTime = inTime;
this.cardStatus = cardStatus;
this.tag = tag;
this.devIdIncar = devIdIncar;
}
public DebitId getId() {
return this.id;
}
public void setId(DebitId id) {
this.id = id;
}
public Integer getCardUid() {
return this.cardUid;
}
public void setCardUid(Integer cardUid) {
this.cardUid = cardUid;
}
public Float getCash() {
return this.cash;
}
public void setCash(Float cash) {
this.cash = cash;
}
public Float getPaidIn() {
return this.paidIn;
}
public void setPaidIn(Float paidIn) {
this.paidIn = paidIn;
}
public Float getBalance() {
return this.balance;
}
public void setBalance(Float balance) {
this.balance = balance;
}
public Timestamp getInTime() {
return this.inTime;
}
public void setInTime(Timestamp inTime) {
this.inTime = inTime;
}
public Integer getCardStatus() {
return this.cardStatus;
}
public void setC