-2
我想在Grails中使用SortedSet
,但我得到的只是一个MissingMethodException。Grails中的SortedSet不起作用
包含有序集合类看起来是这样的:
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。
hmpf,只是一个错字! (`compar_t_eTo`)欢迎来到动态类型的世界;-) – deamon 2010-11-27 16:13:22