eastwater
eastwater

Reputation: 5572

JPA Criteria API: entity type expression

JPQL has entity type expression, e.g.

SELECT e
FROM Employee e
WHERE TYPE(e) IN (Exempt, Contractor)

Does criteria API have entity type expression?

Upvotes: 0

Views: 331

Answers (1)

crizzis
crizzis

Reputation: 10716

Yes. Path.type() creates an Expression corresponding to the type of the given path. You can then create class literals using CriteriaBuilder.literal() for use in comparison expressions.

Upvotes: 1

Related Questions