Hibernate version: 3.2.2 GA
Full stack trace of any exception that occurs:
Name and version of the database you are using: DB2 7.2.5
Hi All,
We have been using hibernate 3.x for the last few months in an application which has about 200 tables and lots of foreign key relationships. We have followed the practice of using cascade=all from the one-to-many side and cascade=none from the many-to-one side of every relationships. We have followed this assuming the standard database practices of avoiding cascades from the child side. Under these settings we were getting lots of TransientObjectException(s). I would say loads of it.
As suggested by the message thrown by the TransientObjectException
(object references an unsaved transient instance - save the transient instance before flushing:) we used lots immediate merge() to overcome this situation, yet we were still getting quite a few TransientObjectException to live with.
During the course of this turmoil one of us found out that all these problems are gone if we change cascade=none form the child side to cascade=all and use a single call to merge(). Ever since we have not got a single TransientObjectException.
I would like to know is this the right approach to use merge() in hibernate? Is there any side effects to this usage of merge on parent +cascade=all from child side
Any input on this will be highly appreciated esp from the hibernate core team.
Thanks,
Hitesh
|