Eclipselink - 在equals中使用主键

时间:2015-07-29 12:33:28

标签: hibernate eclipselink equals hashcode

我读过很多有趣的文章,关于是否在Eclipselink实体中使用主键属性。

如果使用它的首选方式;通过现场访问或getter访问? E.g。

public boolean equals(..) {
 //some code to check class, null, etc.
 if (this.id != other.id)
    return false;
}

public boolean equals(..) {
 //some code to check class, null, etc.
 if (this.getId() != other.getId())
    return false;
}

我已经读过Hibernate(或者以前的版本)使用了代理对象,因此即使this.getId不为null,this.id也可能导致null。 Eclipselink也是如此吗?

谢谢, krisy

0 个答案:

没有答案