Я разрабатываю веб-сайт, которому нужны категории с подкатегориями.Каков идеальный домен класса Grails для этой древовидной структуры
Мой текущий класс домен:
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
}
}
Но это дает мне ошибку:
Property [children] in class [class com.abc.Category] is a bidirectional one-to-many with two possible properties on the inverse side. Either name one of the properties on other side of the relationship [category] or use the 'mappedBy' static to define the property that the relationship is mapped with. Example: static mappedBy = [children:'myprop']
Итак, в чем вопрос? посмотрите, как использовать сопоставленные http://grails.org/doc/2.2.x/ref/Domain%20Classes/mappedBy.html и правильно настроить. Также вам нужно отношение как к родителям, так и к детям, как обычно –