I'm trying to implement a model that handles multi-user concurrent changes. To explain what I'm trying to do, I'll use the example of a group entity containing many person entities.
1. User 1 loads the group named "developers".
2. User 2 loads the same group.
3. User 1 adds "developer1" to the group and saves it.
4. User 2 adds "developer2" to the group and saves it.
5. Both users are able to save their changes without a StaleObjectStateException occuring, because they did not change the group, only its children.
I would like to be able to prevent two users from editting the same group at the same time. It seems like the logical way of doing that is to dirty the parent (group) when the child (person) is added.
Is there an easy way to automatically get hibernate to increment the version of the parent object in this case? Is there a better approach to achieve the same thing? If I have to manually implement dirtying the parent, is there a way to mark an object dirty without changing its values?
Thanks for your help,
Jonathan