转http://lz726.iteye.com/blog/116616
有关lazy的异常分析
对象表识符:
Hibernate 的 pojo 对象
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
public class Department extends BaseObject implements java.io.Serializable {
private Integer id ;
private String depNo ;
private String depName ;
/** default constructor */
public Department() {
}
//getter/setter
public int hashCode() {
return new HashCodeBuilder().append(getId()).toHashCode();
}
public String toString() {
return new ToStringBuilder( this ).append( "id" , getId()).toString();
}
public boolean equals(Object other) {
if ( ( this == other)) return true ;
if (! (other instanceof Department)) return false ;
Department otherDep = (Department) other;
return new EqualsBuilder().append( this .getId(), otherDep.getId()).isEquals();
}
public abstract class BaseObject implements Serializable {
public abstract String toString();
public abstract boolean equals(Object o);
public abstract int hashCode();
}
用业务键值比较对象是否相等 使用 org.apache.commons.lang.包中的方法重写equals和hashcode方法