java-如何使用Criteria API进行JOIN ON查询
作者:互联网
从2.1版开始,JPA支持加入.我发现了几个在JPQL中如何使用join on的示例,但没有针对Criteria API的示例,这是我的问题:
Is
JOIN ON
is implemented in Criteria APi? And if yes, Can anyone provide example?
解决方法:
试试这个
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});
用您要施加的任何ON子句填充“ {some predicate}”.
标签:criteria-api,jpa,jpa-2-1,java 来源: https://codeday.me/bug/20191028/1950254.html