Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Criteria for nested domain objects:
- Product hasMany Contributor has a Artist has a name
- I want to find all products who have an artist with a name
- There are other criteria as well, a Product hasMany Topic has a title - that part works
- */
- String topic = "christmas,easter"
- List topicList = topic.tokenize(",")
- String n = "david,Anne,amy"
- List nameList = n.tokenize(",")
- def c = Product.createCriteria()
- productInstanceList = c.list {
- or {
- topics {
- inList("title", topicList)
- }
- contributors {
- artist {
- inList("name", nameList)
- }
- }
- }
- and {
- eq("isActive", true)
- }
- }
- println productInstanceList
- //exception
- //org.hibernate.QueryException: could not resolve property: artist.name of: com.greenlabelmusic.Contributor
Add Comment
Please, Sign In to add comment