GORM 中的复合外键列

发布于 2024-07-17 10:41:35 字数 114 浏览 1 评论 0原文

我需要在 GORM 中自定义复合外键的列名称,但我没有找到任何说明如何执行此操作的文档。 我知道如何自定义PK列,以及如何自定义单列FK,但不知道如何自定义多列FK。 有可能吗?

谢谢。

I need to customize the column names for composite foreign keys in GORM, and I didn't find any document that shows how to do it. I know how to customize PK columns, and how to customize a single-column FK, but not multi-column FK. Is it possible at all?

Thanks.

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

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

发布评论

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

评论(2

怎会甘心 2024-07-24 10:41:35

具有复合 id 的域类必须实现 Serialized 接口。

class Person implements Serializable {
...
}

A domain class with composite id must implement the Serializable interface.

class Person implements Serializable {
...
}
污味仙女 2024-07-24 10:41:35

您需要在对象映射闭包中使用“id:composite”构造。

我必须去上班,所以这里是简短的:

class Person {
  String firstName
  String lastName

    static mapping = { 
        id composite:['firstName', 'lastName'] 
    } 
}

Grails:对象关系映射

You need the "id: composite" construct in your object mapping closure.

I have to leave for work, so here it is in brief:

class Person {
  String firstName
  String lastName

    static mapping = { 
        id composite:['firstName', 'lastName'] 
    } 
}

Grails: Object Relational Mapping

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