2010-11-27 44 views
-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

回答

5

没有方法签名: java.lang.String。 comparteTo()是参数类型

现在看到的问题适用 ?

+0

hmpf,只是一个错字! (`compar_t_eTo`)欢迎来到动态类型的世界;-) – deamon 2010-11-27 16:13:22

相关问题