这是摘自grails官方网站FAQ里的一个问题
翻译
问题:在一对多的关系中,如何得到一个有序的多对象
在Author和Book例子中,Book 域类(domain class)必须实现Comparable接口,然后把 Author域类里的books类型设置为 SortedSet
源代码同原文
原文:
Q: In a one-to-many relationship, how to do I have a sorted set of the many objects?
In the Author/Book example, Book must implement the Comparable interface, and the set of books must be of type SortedSet:
class Author {
Long id Long version
def relatesToMany = [ books : Book ]
String name SortedSet books
}
原文地址:http://grails.codehaus.org/FAQ