hibernate 无主键表的处理
1、hibernate 无主键表的处理可看成多主键表来处理
2、多主键entity对象定义方式需要实现Serializable接口
并且重写equals(Object obj)和hashCode()两个方法,下面是例子
?
public boolean equals(Object obj) { if(obj == this) { return true; } if(!(obj instanceof Login)) { return false; } Login login = (Login) obj; return new EqualsBuilder() .append(this.branch_no, login.getBranch_no()) .append(this.card_enter, login.getCard_enter()) .append(this.teller_no, login.getTeller_no()) .append(this.time, login.getTime()) .append(this.frequency, login.getFrequency()) .isEquals(); }public int hashCode() { return new HashCodeBuilder() .append(this.branch_no) .append(this.card_enter) .append(this.teller_no) .append(this.time) .append(this.frequency) .toHashCode(); }?