我试图通过使用下面的代码
将一些ccondition放在一个实体上 @OneToOne
@JoinColumn(name = "USA_ID", insertable = false, updatable = false)
@Where(clause = "OBJ_TYPE = 8")
private Object object;
这是生成如下sql somithig(不包括where条件): 休眠:
select object0_.OBJ_ID as OBJ1_553_0_, object0_.OBJ_TYPE as OBJ2_553_0_, object0_.OBJ_STATUS_CD as OBJ3_553_0_ from MARTINI_STORE.OBJECT object0_ where object0_.OBJ_ID=?
@Where与@OneToMany合作......但我的要求是将条件放在@OneToOne的被判实体中。
我在这里做错了什么?
Entity 1:
public class ObjectAttribute{
@OneToOne
@JoinColumn(name = "ATR_ID", insertable = false, updatable = false)
@Where(clause = "NAME IN ('XYZ')")
private Attribute attribute;
}
实体2:
public class Attribute {
@Id
@Column(name = "ATR_ID", nullable = false)
private long atrId;
}