GORM tablePerHierarchy为假,外键

问题描述

| 我的模型中有:
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没有得到回答! 谢谢     

解决方法

在休眠文档中说   三个子类表具有主   与超类的关键关联   表,所以关系模型是   实际上是一对一的关联 在每个子类的表示例中。 我认为这意味着您不会看到外键。对于数据库中的Winner行,您应该看到ContentParticipant的主键与Winner的主键匹配。     

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...