Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Grails中指定hasOne属性的表名_Grails_Gorm - Fatal编程技术网

如何在Grails中指定hasOne属性的表名

如何在Grails中指定hasOne属性的表名,grails,gorm,Grails,Gorm,我使用hasOne实现Grails中的一对一关系: class MyParent { static hasOne = [child: MyChild] } class MyChild { static belongsTo = [parent: MyParent] static mapping = { table: 'MyChild' } } 我在数据库中有一个名为“MyChild”的表,因此我得到了下一个错误: Invalid object n

我使用
hasOne
实现Grails中的一对一关系:

class MyParent {
    static hasOne = [child: MyChild]
}

class MyChild {
    static belongsTo = [parent: MyParent]
    static mapping = {
        table: 'MyChild'
    }
}
我在数据库中有一个名为“MyChild”的表,因此我得到了下一个错误:

Invalid object name 'my_child'
如何在
Parent
类中将关系的表名指定为“MyChild”而不是“my_child”?

尝试不使用“:”

static mapping = { table "mychild"} 
或使用名称标签

static mapping = { table name:"mychild" }

希望这有帮助

在没有“:”的情况下尝试一下。静态映射={table“mychild”}或使用名称标签静态映射={table name:“mychild”}谢谢,Alidad,这正是问题所在!:)