0

I have an Entity called ArtWork and the Entity has attribute List<Style> styles, the list may have n number of styles.

Style has attribute called title

I require a Hibernate query that returns all artworks which has a style title="Abstract"

-Thanks for your help

1 Answers1

1

Single title:

select a from ArtWork a inner join a.styles style where style.title = 'Abstract'

Multiple titles:

Provide a named parameter list.

List<String> titles = ... // Your titles
session.createQuery("from ArtWork a inner join a.styles style where style.title in (:titles)").setParameterList("titles", titles);
TJ-
  • 14,085
  • 12
  • 59
  • 90