4

Since version 2.1 JPA supports join on. I found few examples how to use join on in JPQL but none for Criteria API, and here is my question:

Is JOIN ON is implemented in Criteria APi? And if yes, Can anyone provide example?

user902383
  • 8,420
  • 8
  • 43
  • 63

1 Answers1

6

Try something like this

CriteriaQuery<Person> crit = cb.createQuery(Person.class);
Root<Person> candidateRoot = crit.from(Person.class);
Join<Person, Address> addrJoin = candidateRoot.join(Person_.address, JoinType.INNER);
addrJoin.on({some predicate});

filling "{some predicate}" with whatever ON clause you want to impose.

Neil Stockton
  • 11,383
  • 3
  • 34
  • 29