I have entity called Issue and entity called UserIssue. UserIssue extends Issue.
@Inheritance(strategy = InheritanceType.JOINED)
@Entity(name = "ISSUE")
public class Issue extends VersionedSequenceIdEntity {
... all fields
}
@Entity(name = "USER_ISSUE")
public class UserIssue extends Issue {
...
@Enumerated(EnumType.STRING)
@Column(name = "CATEGORY", nullable = false)
private IssueCategory category;
...
}
I need to do e.g. something like this:
Predicate predicate= root.get("category").in(IssueCategory.CATEGORY_1, IssueCategory.CATEGORY_2);
The problem is that root is instance of Root<Issue> but "category" field is defined on subclass UserIssue so the line of code obviously does not work.
Is there a way how to build a predicate that creates where condition for subclass field? I have only instance of Root<Issue>, CriteriaQuery and CriteriaBuilder.
Thank you, Lukas