1. Using HQL query
def results = Book.findAll(" from Book as b where :title = b.author.name) ", [title:"Mr Author"])
2. Using criteria with createAlias()
def results = Book.withCriteria {
createAlias("author", "a")
eq("a.name", "Mr Author")
}I hope this helps some of you out there. For some reason "createAlias" is not well documented in the Grails documentation, unless you cross reference the Hibernate docs.
0 comments:
Post a Comment