Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.1.3
id generated with cascading save update not rolled back after transaction rolls back
I have the following problem:
Two classes Person and PersonInfo are mapped, such that Person has a one-to-one mapping to PersonInfo, with a cascading SAVE_UPDATE. I am using @Id @Generated annotation on both classes.
While doing testing I tried to persist a Person object with a violated constraint( not null property ).
The transaction was successfully rolled back and both the Person and PersonInfo object were not persisted.
However the id in PersonInfo is not set back to null, whereas in Person it is set back to null.
How do I fix this problem? I cannot set the null property and try to persist again as hibernate thinks that PersonInfo is persistent and does not find the matching object in the database.
Currently what I am doing is this, after I fix the null property, I make the id for PersonInfo null, before persisting the Person object again.
This is an easy solution for the given case, but I have other classes that have more complicated SAVE_UPDATE cascades, and cleaning those objects would be hard.
Has anyone had this problem before? How can I fix it?
Thank you