【问题标题】:Grails create table List<String> nameGrails 创建表 List<String> 名称
【发布时间】:2013-03-02 03:58:49
【问题描述】:

为什么我不能在我的数据库中创建表列表?

我的域类:

class Test {
   List<String> names
}

【问题讨论】:

    标签: grails grails-domain-class


    【解决方案1】:

    这是支持的语法:

    class Test {
       static hasMany = [names: String]
    }
    

    【讨论】:

    • 嗨,Burt,谢谢你的回答,但你能告诉我另一种在没有 hasMany 的情况下保存 List 的方法吗,谢谢
    • 这取决于您希望数据如何存储在数据库中。从那里向后工作。
    【解决方案2】:

    我正在使用问题中公开的方式并且它正在工作。

    class Test {
       List<String> names
    }
    

    这会生成一个名为:test_names 的表,其中包含 test_names_id, names_ids, names_ids_idx 列。

    【讨论】:

    • 有人知道如何对这个名称字段进行分页吗?
    猜你喜欢
    • 2021-09-04
    • 2019-04-12
    • 2020-03-10
    • 1970-01-01
    • 2019-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多