【发布时间】:2012-11-11 20:29:46
【问题描述】:
我有以下两个域类, 用户和帖子 我在他们之间有两种关系, 用户有一对多的帖子和反向引用。 用户与他关注的帖子具有多对多关系: 我得到的关系如下:
User {
hasMany = [posts : Post, followingPosts: Post]
belongsTo = [Post] //For the many-to-many, this is the owner i'd like to have.
}
Post {
hasMany = [followers: User]
belongsTo = [owner: User] //For the 1-to-Many, this is my back-reference
}
现在我遇到了与 Grails 的冲突,我尝试通过映射解决它但没有成功,这是我得到的错误:
Domain classes [Post] and [User] cannot own each other in a many-to-many relationship. Both contain belongsTo definitions that reference each other. (Use --stacktrace to see the full trace)
有人知道怎么解决吗?
【问题讨论】:
标签: java grails grails-orm entity-relationship relationship