@Getter
@Setter
@ToString
@ApiModelProperty("contains ignore case")
private String name;
@ApiModelProperty("equals")
private String department;
@ApiModelProperty("in equals")
private List<String> position;
@ApiModelProperty("greater or equals")
private Integer salaryFrom;
@ApiModelProperty("lower or equals")
private Integer salaryTo;
@ApiModelProperty("contains ignore case")
private String email;
@ApiModelProperty("at least one with priority higher")
private Integer oneHigher;
@ApiModelProperty("all priorities higher")
private Integer allHigher;
BooleanBuilder conditions = new BooleanBuilder();
ofNullable(salaryFrom).map(employee.salary::goe).ifPresent(conditions::and);
ofNullable(salaryTo).map(employee.salary::loe).ifPresent(conditions::and);
ofNullable(email).map(employee.email::containsIgnoreCase).ifPresent(conditions::and);
ofNullable(oneHigher).map(employee.tasks.any().priority::goe).ifPresent(conditions::and);
return conditions;
我有一个Employee实体,该实体具有Task
集,我希望能够仅查询所有任务的优先级都高于某个优先级的员工。我可以使用any()来实现这一点,但当至少一个任务的优先级高于某个值时,我无法找到针对所有任务执行此操作的方法,因为我无法在employee.tasks
中迭代任务
1条答案
按热度按时间cpjpxq1n1#
我不知道如何用QueryDSL对此建模,但通常在HQL中,这可以通过使用exists子查询来建模,例如:
另一种表述方式是使用量词