gpt4 book ai didi

grails - 导致多对多关系

转载 作者:行者123 更新时间:2023-12-02 15:39:12 25 4
gpt4 key购买 nike

我正在尝试在Grails 1.3.4上建立多对多关系,并且遇到了这个异常:

Caused by: org.codehaus.groovy.grails.exceptions.GrailsDomainException: No owner defined between domain 
classes [class gblog.Post] and [class gblog.Comentario] in a many-to-many relationship.
Example: static belongsTo = gblog.Comentario

Comentario的代码是:
package gblog

class Comentario {

static constraints = {
}

String conteudo
Date data

static belongsTo = [post:Post, autor:Usuario]
static hasMany = [posts:Post]
}

Post的代码是:

软件包gblog
class Post {

static constraints = {
}

String titulo
String conteudo
String palavrasChave
Date data

static belongsTo = [categoria:Categoria, autor:Usuario]
static hasMany = [comentarios:Comentario]
}

谢谢大家!

最佳答案

我认为Grails在这里变得困惑:

static belongsTo = [post:Post, autor: Usuario]
static hasMany = [posts:Post]

您可能想要绘制所有类之间的交互方式,因为我认为这有点差。

关于grails - 导致多对多关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3504460/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com