开发者

Grails "not-null property references a null or transient value" exception on web flow

I'm getting "org.springframework.dao.DataIntegrityViolationException: not-null property references a null or transient value: A.b" exception on web flow in grails 1.1.2. there is

class B {
   ...
   static belongsTo = [a:A]
   ...
}

and

cl开发者_如何学Pythonass A {
   ...
   static hasMany = [b:B]
   ...
}

Does anyone know what is wrong? Thanks Tom


Solved.

There was a different problem. I wasn't persisting anything. There appeared some inconsistences between serialized data in the flow and persisted data in the database. So a select query caused this exception.


This is really going to depend most on what your parameters are and how you're handling creation or maintenance of the GORM objects, not your actual object graph.


Agree with @John. One of the common solutions is, you should be saving the object as

a.addToB(b)
a.save()

Hope it helps.


This problem is related to the ORM (I guess you are using hibernate below). The problem will be solved if you configure the cascade property of the mapped attributes.

I don't know how to configure it in grails, but this doc of hibernate should help you to understand where the problem is: http://docs.jboss.org/hibernate/stable/entitymanager/reference/en/html/objectstate.html#objectstate-transitive

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜