-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