我正在使用JPA 2.1。我有3个实体:Dr01
,Dr02
和Dr03
,结构如下:
public class Dr01 implements Serializable {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "dr01")
private List<Dr02> dr02List;
}
public class Dr02 implements Serializable {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "dr02")
private List<Dr03> dr03List;
@JoinColumn(name = "DR2CLM", referencedColumnName = "DR1CLM", insertable = false, updatable = false)
@ManyToOne(optional = false)
private Dr01 dr01;
}
public class Dr03 implements Serializable {
@JoinColumns({
@JoinColumn(name = "DR3CLM", referencedColumnName = "DR2CLM", insertable = false, updatable = false),
@JoinColumn(name = "DR3PTFN", referencedColumnName = "DR2PTFN", insertable = false, updatable = false)})
@ManyToOne(optional = false)
private Dr02 dr02;
private elementOBJ element;
}
public class elementOBJ implements Serializable {
@Column(name = "XXX")
private int id;
@Column(name = "YYY")
private int status;
}
我想从Dr01
中进行选择,只获取状态字段中包含值为1的元素对象的Dr03
个对象。
如何检索由其状态值过滤的dr03List? (在选择之后不过滤。)
感谢提前。
答案 0 :(得分:0)
可能有帮助的选项: