问题描述
我有一个名为持有一国领域枚举基地实体。
I have a base entity that holds a enum field called State.
public enum State {
DELETED(0),
ACTIVE(1)
;
private int value;
private State(int value) {
this.value = value;
}
public int getValue() {
return this.value;
}
}
有没有JPA注释的方法来设置生成的查询的WHERE子句只检索实体状态字段是ACTIVE?
原因是,如果我有一个实体A持有实体B的列表,当我从数据库中检索A的实例,并初始化它,我想B的名单只有持有其中,实体提交的国家是ACTIVE
Is there a JPA annotated way to set the where clauses of the generated queries to retrieve only entities that the state field is "ACTIVE"?
The reason is that if i have an entity "A" that holds a list of entities "B", when i retrieve from the DB an instance of "A" and initialize it, i want the list of "B" to hold only the entities where the State filed is "ACTIVE"
推荐答案
有没有过滤器或其中JPA注解,也没有办法使用注释来筛选集合实体。
There is no filter or where annotations in JPA and there is no way to filter collection entities using annotations.
我建议你检索单位和只取积极乙实体。
I suggest you retrieving A entities and fetching only active B entities.
这篇关于设置在那里实地条款的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!