Guest User

Untitled

a guest
Sep 17th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 0.82 KB | None | 0 0
  1. /*
  2. Criteria for nested domain objects:
  3. Product hasMany Contributor has a Artist has a name
  4. I want to find all products who have an artist with a name
  5. There are other criteria as well, a Product hasMany Topic has a title - that part works
  6. */
  7. String topic = "christmas,easter"
  8. List topicList = topic.tokenize(",")
  9. String n = "david,Anne,amy"
  10. List nameList = n.tokenize(",")
  11.  
  12. def c = Product.createCriteria()
  13. productInstanceList = c.list {
  14.    or {
  15.        topics {
  16.             inList("title", topicList)
  17.         }
  18.        contributors {
  19.            artist {
  20.             inList("name", nameList)
  21.            }
  22.         }
  23.     }
  24.     and {
  25.        eq("isActive", true)
  26.     }
  27. }
  28. println productInstanceList
  29.  
  30. //exception
  31. //org.hibernate.QueryException: could not resolve property: artist.name of: com.greenlabelmusic.Contributor
Add Comment
Please, Sign In to add comment