Hibernate HQL Select Query Based on Item in a One-to-Many Relationship
class Order { private List<Item> items; //more code ... } class Item { private String itemId; private String name; //more code ... }
With native SQL it was not that difficult, but since I've used Hibernate I wanted to find a way to do it in HQL. After some searching in Google I found out how to do it.
select o from Order o left join o.items its where its.itemId = :itemId
Would be better to use an inner join as opposed to a left outer join.
Post a Comment