I have the following grails domains (example):
// a member of the library
class LibraryUser {
string name
}
// a book
class Book {
string title
string author
}
// association which user currently has which book checked out
class Checkout {
LibraryUser user
Book book
}
How can I retrieve an alphabetically sorted list of books that a given user has currently checked out? (using a criteria query)
A similar question is if I do not explicitely code the Checkout table but instead do a has-many:
// a member of the library
class LibraryUser {
string name
static hasMany = [ books : Book ]
}
// a book
class Book {
string title
string author
}
How would I use a criteria query here to retrieve an alphabetically(!) sorted list of all currently checked out books for a given user?