Grails关系不保存

Grails关系不保存,grails,gorm,Grails,Gorm,我有以下设置: class Parent { static hasMany = [ children: String ] } class ParentController { def create() { Parent entry = params.id ? Parent.load(params.id as long) : new Parent() entry.properties = params if (reques

我有以下设置:

class Parent {

    static hasMany = [ children: String ]

}


class ParentController {

    def create() {
        Parent entry = params.id ? Parent.load(params.id as long) : new Parent()

        entry.properties = params
        if (request.method == "POST") {         
            if (entry.validate()) {

                entry.save()
                assert !entry.hasErrors()

                println entry.children // prints [two, one]

                println Parent.load(entry.id).children // prints []
                redirect(action:'index')
                return
            }
        }
        return [
            entry: entry,
            entities: ["one","two"]
        ]

    }

}
为什么孩子们不和父母一起存钱


(我还试着让孩子们成为另一个域对象,但是没有什么不同)

虽然我不确定是什么解决了我的问题,但将
save()
更改为
save(flush:true)
允许我查看Hibernate引发的异常。

当您只想在关系中搜索id时,通常使用Load。更改为
get()
有帮助吗?谢谢您的想法,但是get()没有任何区别(我实际上是在应用程序中的另一个没有子项的点上执行list(),我添加了上面的行以进行调试)