Search code examples
grailsgroovygrails-orm

Grails -Custom Sorting with associated domain class


I have domain

Training

class Training {

       static belongsTo = [venue: Venue]
 }

Venue

  class Venue {
        static belongsTo = [city: City]
  }

City

 class City {
  String name
}

now i want to sort Training based on City name . is there a way to do it in Grails (Gorm)way?


Solution

  • have you tried

    def results = Training.withCriteria {
        order('venue.city.name', 'asc')
    }