Skip to content Skip to sidebar Skip to footer

Convert Simple Sql Query To Jpa... Onetomany Relationship

I have a JPA (Hibernate) model...One object contains a List of other objects. If i want to run a SQL query to search BOTH objects it is relatively straightforward, I do a LEFT JOIN

Solution 1:

select distinct p from Person p
left join fetch p.records r
where p.name like :search 
  or r.factor1 like :search

You will need to add % characters around search before you pass it as a parameter.


Post a Comment for "Convert Simple Sql Query To Jpa... Onetomany Relationship"