I've been doing some testing and want to validate that my findings are correct behavior for Hibernate.
I'm finding that cascade="merge, delete-orphan" on a one-to-many causes version updates on the parent object only if the membership of the collection representing the one-to-many changes. If I update a property on a member of the collection and call merge on the parent, no version update on the parent happens. If I remove or add a member to the collection, the version on the parent gets updated. Is this intended behavior. I could see an argument to update the version of the parent on any changes to the collection, for the sake of consistency (i.e. the business meaning of fields in the parent may be related to the contents of the collection, hence you want a stale state exception if the collection has changed), but only updating the version for collection size changes but not for updates to the members of the collection doesn't make a whole lot of sense to me.
Also, does Hibernate support some way to explicitly control this (whether the parent's version gets updated)?
|