如何在QueryDSL A OR (B AND C)
进行以下声明?
Let's say you have a Person Entity as follows
@Entity
public class Person {
@Id
@GeneratedValue(strategy = AUTO)
private Long id;
private String username;
private Integer age;
// Getter, Setter, Constructors as required
}
You have a query object like below
QPerson personA = new QPerson("a");
QPerson personB = new QPerson("b");
QPerson personC = new QPerson("c");
Assuming all are Person class query object
You can create a Predicate like below
BooleanExpression A = personA.username.eq("X");
BooleanExpression B = personB.username.eq("Y");
BooleanExpression C = personC.username.eq("Z");
Then you can combine the BooleanExpression (Predicate) like below
A.or(B.and(C))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.