September 12, 2009

Grails PSA – Hibernate Exception w/a _backRef

Let’s say you have two domain objects/models – Feet and Toes.

Obviously, in general a Foot hasMany toes

and obviously (at least we hope) a toe belongsTo a foot.

So given this, if you, say, changed the color of the toenail on a toe, you would expect to then do a toe.save(), right?

WRONG!   You get this crazy _backRef exception and you’re dead in the water.

Instead, what you have to do is save the Foot, and it cascades down and saves the toe.

*boggle*

http://jira.codehaus.org/browse/GRAILS-3783