Hi Dale,

Dale Newfield wrote:
Rob Hills wrote:
My problem arises when using this last form. If I watch the database while navigating through the Grandparent edit form to the Parent edit form, I see that the version number for the selected Grandparent record increments once when going to the Grandparent edit form and then again AFTER going to the Parent edit form. Hence, when I submit the Parent edit form, it's rejected because it has the wrong version in its hidden field. If I use Firebug to increment the hidden version on the Parent edit form, it saves without a problem.

I don't understand why displaying an edit form (inherently a read-only task) should effect the version number? I would assume the version numbers should only be changing when a save happens...
From my understanding of Hibernate, each time hibernate loads an entity for editing, it increments the version number in the DB. That is its method for preventing multiple concurrent edits from overwriting one-another. I believe, it works like this:

A record sitting in the db has the version no 0.
User A opens a form to edit the record and hibernate increments the version to 1. User A then and goes off for coffee without saving his edits. User B opens a form to edit the same record. Hibernate increments the version to 2. User B has had enough coffee already and completes his changes and clicks the "Save" button. Hibernate compares the version number presented by User B's app (2) against the DB, finds they're still the same and allows the data to be saved. User A comes back from his coffee, finishes editing and clicks "Save". Hibernate compares the version of User A's data (1) with that in the DB (2) and bugs out with a "Stale Object"
exception.

If anyone who knows this stuff better than I do sees anything wrong with this potted description, please pipe up.

Cheers,
Rob Hills
Waikiki, Western Australia

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to