Grails 中的 SortedSet 不起作用

发布于 2024-10-04 21:54:07 字数 1043 浏览 0 评论 0原文

我想在 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)

我的示例几乎与来自官方参考的示例

I want to use a SortedSet with Grails, but all I get is a MissingMethodException.

The class that contains the sorted set looks like this:

class SystemUser {

    SortedSet organisations
    // ... some other fields

    static hasMany = [organisations: Organisation]
    static belongsTo = [Organisation]

}

... and the class implementing Comparable like this:

class Organisation implements Comparable {

    String name
    // ... some other fields

    static hasMany = [users: SystemUser]

    int compareTo(other) {
        return name.comparteTo(other.name)
    }

}

When I try to save a SystemUser object I get this Exception message:

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)

My example is almost identical with the example from the official reference.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

栖迟 2024-10-11 21:54:07

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

现在看到问题了吗?

No signature of method:
java.lang.String.comparteTo() is
applicable for argument types

See the problem now?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文