Grails GORM tablePerHierarchy不';不要创建表
我需要有两个从一个域扩展而来的域。但是,当我创建域时,不会创建子域的表Grails GORM tablePerHierarchy不';不要创建表,grails,gorm,relationship,Grails,Gorm,Relationship,我需要有两个从一个域扩展而来的域。但是,当我创建域时,不会创建子域的表 class BaseEntity { Date created Boolean isDeleted Date modified Integer version static mapping = { tablePerHierarchy false version false table name: "base_entity", schema: "user" isDelet
class BaseEntity {
Date created
Boolean isDeleted
Date modified
Integer version
static mapping = {
tablePerHierarchy false
version false
table name: "base_entity", schema: "user"
isDeleted defaultValue: Boolean.FALSE
}
}
第一个域扩展自BaseEntity
class UserEx extends BaseEntity {
String firstName
String lastName
String password
String userName
static mapping = {
version false
table name: "user_ex", schema: "user"
}
}
这是第二个域
class UserType extends BaseEntity {
Integer name
static belongsTo = [parent: UserType]
static hasMany = [child:UserType]
static mapping = {
version false
table name: "user_type", schema: "user"
}
}
在数据库中,唯一创建的表是BaseEntity。若我从BaseEntity域中删除tablePerHierarchy属性,则创建的表(即BaseEntity)包含userEx和userType的所有字段—这不是我们想要的-
总而言之,我希望在数据库中有这三个表,而不丢失扩展关系
提前感谢tablePerHierarchy false“应该”触发创建新表。也许是个愚蠢的问题,但是子类是否也在grails app/domain文件夹中,您还没有将它们放在src下,是吗?@Dave:D它们也在domain文件夹中。我正在使用IntelliJ,所以很难犯这样的错误:D:-)不得不问显而易见的问题。您是否尝试过使用干净的数据库?datasource.groovy中的dbCreate参数设置为什么?@Dave是的。我还尝试将数据库从postgresql更改为oracle。。dbCreate参数设置为“更新”是否需要“表格”行?我从来都不需要使用这些,我还想知道为什么映射中有actionPriority,但没有定义actionProperty字段。与UserEx中的已删除条目类似。能否确认根本没有创建UserEx和UserType表?tablePerHierarchy false“应该”触发要创建的新表。也许是个愚蠢的问题,但是子类是否也在grails app/domain文件夹中,您还没有将它们放在src下,是吗?@Dave:D它们也在domain文件夹中。我正在使用IntelliJ,所以很难犯这样的错误:D:-)不得不问显而易见的问题。您是否尝试过使用干净的数据库?datasource.groovy中的dbCreate参数设置为什么?@Dave是的。我还尝试将数据库从postgresql更改为oracle。。dbCreate参数设置为“更新”是否需要“表格”行?我从来都不需要使用这些,我还想知道为什么映射中有actionPriority,但没有定义actionProperty字段。与UserEx中的已删除条目类似。能否确认根本没有创建UserEx和UserType表?