我有以下两个领域类, 用户和帖子 并且它们之间有两个关系, 用户与帖子具有反向引用的1对多关系。 用户与他关注的帖子之间具有多对多关系: 我的关系如下:
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)
有人知道如何解决这个问题吗?