In the Hibernate 3.0 Docs Chapter 11 talks about this issue.
It also talks about Detached Objects, and Long Sessions. I am just a bit confused how hibernate implements the optimistic concurrency and what settings I need to set up to allow hibernate to handle my versioning.
So say, In a web app I am updating a users profile the same time someone else is updating the same user profile (2 different sessions). The object used to represent the data has become detached because it was just needed for the view.
I make my changes first and commit them. The second user finishes and tries to submit his changes. The way the concurrency works is just by throwing the staleobject exception? And hibernate knows it is stale through the versioning?
So to handle this exception, I could just alert the second user the data is old? So that essentially is how hibernate does concurrency?
And is this equivalent to using the automatic concurrency idiom, along with the detached object
pattern?
And in theory I could be using automatic versioning with detached objects and have a long session open all at once (That would probably be bad code though).
And along those lines, what's the difference between caching an object in the SessionFactory, so all sessions are working with the same object?
Also, is there a best practice or pattern to allow hibernate to handle concurrency among multiple servers.
Sorry, for all this just jumbled together. And thanks for your assistance in advance!
-Jonathan