【发布时间】:2010-11-27 15:52:44
【问题描述】:
我想在 Grails 中使用 SortedSet,但我得到的只是一个 MissingMethodException。
包含排序集的类如下所示:
class SystemUser {
SortedSet organisations
// ... some other fields
static hasMany = [organisations: Organisation]
static belongsTo = [Organisation]
}
...以及像这样实现Comparable 的类:
class Organisation implements Comparable {
String name
// ... some other fields
static hasMany = [users: SystemUser]
int compareTo(other) {
return name.comparteTo(other.name)
}
}
当我尝试保存 SystemUser 对象时,我收到以下异常消息:
groovy.lang.MissingMethodException: No signature of method: java.lang.String.comparteTo() is applicable for argument types: (java.lang.String) values: [ABC]
Possible solutions: compareTo(java.lang.String), compareTo(java.lang.Object)
我的示例与example from the official reference 几乎相同。
【问题讨论】:
标签: java grails groovy comparable sortedset