Grails withCriteria fetch, or a fast way to sort in predetermined order
问题 A database function returns id's of all events within a certain radius, ordered by their distance. Afterwards, to preserve performance I'm eagerly loading necessary collections in withCriteria like this: def events = Event.withCriteria { 'in'('id', ids) fetchMode("someRelation", FetchMode.JOIN) // a few more joins setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY) } However this messes up the ordering. I've noticed that the result of this criteria query returns all events sorted