这是摘自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
本文介绍在Grails框架中如何实现一对多关系下多对象的有序集合。通过让Book类实现Comparable接口,并将Author类中的books属性类型设为SortedSet来达到目的。
76

被折叠的 条评论
为什么被折叠?



