我正在开发一个需要带有子类别的类别的网站。
我当前的域类是:
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']