Host.createCriteria().list { createAlias("site", "s") order("s.name", "asc") }
Without "createAlias", the query would be an outer join on "site", but because we are trying to sort by site.name, "createAlias" makes the query an inner join, so all results where the site is null are lost. Using regular HQL would help us in this situation:
Host.findAll("from Host as h \ left outer join h.site as s order by s.name asc")
No comments:
Post a Comment