mysql - GORM tablePerHierarchy false,外键

标签 mysql hibernate grails grails-orm

我的模型中有:

class ContestParticipant{
    static mapping = {
        id generator: "uuid"
        tablePerHierarchy false
    }
    String id
    Contest sweepContest
    Client client
    String email
}


class Winner extends ContestParticipant{

...

}

我的问题是,为什么在表 Winner 中没有为其父表创建 FK?!

同样的问题:https://stackoverflow.com/questions/3620158/in-grails-setting-tableperhierarchy-false-doesnt-create-a-foreign-key-relations没有得到答复!

谢谢

最佳答案

在 hibernate 文档中它说

The three subclass tables have primary key associations to the superclass table so the relational model is actually a one-to-one association

在每个子类的表示例中。

我认为这意味着您不会看到外键。对于数据库中的 Winner 行,您应该看到 ContentParticipant 的主键与 Winner 的主键匹配。

关于mysql - GORM tablePerHierarchy false,外键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6129077/

相关文章:

hibernate - 基于独立条件的 createAlias (GORM)

java - 从 Spring 3 升级到 Spring 4 后,HibernateTemplate 出现不兼容类型错误

java - 将 SQL native 查询转换为 Spring 数据 JPA

java - Spring PagedListHolder 获取所有记录

tomcat - grails run-app 从根上下文提供文件

mysql - 如何从该特定数据库布局中的歌曲表中选择 Songnames.id?

mysql - 带或不带括号的求和和比较

php - 在 mysql 中与 2(varchar 列)建立关系时出错

javascript - 对 HTML div 进行排序

grails - Groovy 动态调用的类和查找方法不起作用?