jquery - JPA query: Listing a entity based on boolean in sub-set
问题描述
So i got this Spring-boot backend and one of my entities looks like this:
@Entity
@Table( name = "users",
uniqueConstraints = {
@UniqueConstraint(columnNames = "username"),
@UniqueConstraint(columnNames = "email")
})
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@NotBlank
@Size(max = 20)
private String username;
@NotBlank
@Size(max = 50)
@Email
private String email;
@NotBlank
@Size(max = 120)
private String password;
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable( name = "user_roles",
joinColumns = @JoinColumn(name = "user_id"),
inverseJoinColumns = @JoinColumn(name = "role_id"))
private Set<Role> roles = new HashSet<>();
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Set<FileDB> files = new HashSet<>();
@OneToOne(mappedBy = "user", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private DeclarationOfHealth declarationOfHealth;
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Set<CaseHistory> caseHistory = new HashSet<>();
Now The Entity "CaseHistory" has a boolean named "Finished" which indicates if the case is closed or not.
My Question is: Is there anyway to list Users with jpa query based on if the boolean Finished in CaseHistory is true.
i tried List<User> findByCaseHistory_FinishedFalse();
but this gave me one user who had 4 open cases 4 times.
Thx in advance.
解决方案
推荐阅读
- javascript - 如何告诉javascript用户在提示框中输入了一个字符串并在if语句中使用它
- mysql - mysql触发器中的多个变量
- google-oauth - Google OAuth 同意书不允许我提交验证
- javascript - 代码在窗口调整大小中完美执行,但使用窗口恢复按钮会导致不同的结果
- c# - 如何在原始 TextChange 方法后面进行覆盖
- android - 立即打开对话框,然后为对话框加载内容
- scala - 如何同时使用 Scala 格式和替换插值?
- ios - 在 iOS 中使用 opentok 进行屏幕共享
- c# - 图像处理:Sobel 滤镜的结果原来是灰色而不是黑白?
- ios - 生成配置文件和证书时出现 NativeScript Sidekick 错误