How to write query(include subquery and exists) using JPA Criteria Builder

后端 未结 2 790
梦如初夏
梦如初夏 2021-02-06 10:39

Struggling to write the following query using JPA.

Oracle Query:

Select * from table1 s
where exists (Select 1 from table2 p
              INNER JOIN tab         


        
2条回答
  •  悲哀的现实
    2021-02-06 11:18

    You can do it much simpler using JPA Queries or HQL instead of Criteria builders:

    SELECT e1 from Entity1 as e1 
    where exists
    (select e2 from Entity2 as e2 join e2.e3 as ent3
    where ent3.id=e1.id and e2.name='Test')
    

提交回复
热议问题