http://www.intelligrape.com/blog/2011/11/01/criteria-query-with-left-outer-join/
http://stackoverflow.com/questions/17083204/criteria-uses-inner-join-instead-left-join-approach-by-default-making-my-que
http://stackoverflow.com/questions/19390720/grails-2-x-createcriteria-or-doesnt-work-for-nested-associations/19391255#19391255
Now, I do something like this:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def criteria = Spot.createCriteria() | |
def result = criteria.list { | |
eq("slide.id", params.long("id")) | |
createAlias('layoutSpot', 'lSpot', CriteriaSpecification.LEFT_JOIN) | |
createAlias('lSpot.sample', 'smpl', CriteriaSpecification.LEFT_JOIN) | |
projections { | |
property "id" | |
property "signal" | |
property "block" | |
property "row" | |
property "col" | |
property "smpl.name" | |
property "smpl.type" | |
property "smpl.target" | |
} | |
order('block', 'asc') | |
order('row', 'desc') | |
order('col', 'asc') | |
} |
No comments:
Post a Comment