views:

31

answers:

1

Hi,

I'm trying to do a many-to-many relationship on Grails 1.3.4 and I'm getting this exception:

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

The code for Comentario is:

package gblog

class Comentario {

    static constraints = {
    }

    String conteudo
    Date data

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

The code for Post is:

package gblog

class Post {

    static constraints = {
    }

    String titulo
    String conteudo
    String palavrasChave
    Date data

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

Thanks everybody!

A: 

I think Grails is getting confused here:

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

You might want to diagram how all of the classes are interacting, because I'm thinking that this is a little off.

Pat
Thanks man!After a while I saw that things were wrong.
LaSombra