【发布时间】:2013-05-21 05:55:44
【问题描述】:
我正在开发一个需要包含子类别的类别的网站。
我当前的域类是:
package com.abc
class Category {
String title
String description
Category parent
static hasMany = [children: Category, listing: Listing]
static constraints = {
title blank: false
description blank: true
}
}
但它给了我一个错误:
类 [class com.abc.Category] 中的属性 [children] 是 双向一对多,在逆上有两个可能的属性 边。要么命名另一侧的属性之一 关系 [类别] 或使用 'mappedBy' 静态定义 映射关系的属性。示例:静态 mappedBy = [children:'myprop']
【问题讨论】:
-
那么问题是什么?查看如何使用 mappedby grails.org/doc/2.2.x/ref/Domain%20Classes/mappedBy.html 并正确配置。你也需要像往常一样与父母或孩子建立关系
标签: grails tree-structure