I want to check discriminator type in jpa named query like any other attribute.
How can I check?
I want to check discriminator type in jpa named query like any other attribute.
How can I check?
Use TYPE in JPA 2.0: "select p from Employee e join e.projects p where type(p) = LargeProject"
You could use the Criteria API: https://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/Criteria
But this would be quiet overkill.
Use the JPA TYPE()
so a Query could look like this:
SELECT s FROM Superclass s WHERE TYPE(s) = Superclass
This will compare the value set as DiscriminatorValue, so it acts like instanceof
.