我有一个父实体,必须在其中使用@ManyToOne
加入子实体。我想在@Where
中使用@ManyToOne
子句。
Hibernate查询未考虑@Where
子句。
有什么解决方法吗?
我还在子实体级别提供了@Where
子句,但没有用
public class Employee() {
@Id
@Column(name = "Emp_id")
private Integer empId;
@Column(name = "cmp_id")
private Integer cmpId;
@ManyToOne
@JoinColumn(name = "cmp_id", referencedColumnName = "cmp_id", insertable = false, updatable = false)
@Where(clause = "cmp_cl_id =1")
private Student student ;
}
public class Student() {
@Id
@Column(name = "cmp_id")
private Integer cmpId;
@Column(name = "cmp_cl_id ")
private Integer cmpClId ;
}