首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

hibernate 无主键表的处置

2012-09-21 
hibernate 无主键表的处理1、hibernate 无主键表的处理可看成多主键表来处理2、多主键entity对象定义方式需

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();    }
?

热点排行