We call that "application transaction". Bascially, you load a Cat in a database transaction A and send it to the UI. After some time, the user clicks "OK" and the Cat should be saved, this requires a second database transaction B.
In B, we perform a version check (using a version column or a timestamp) to ensure that no other concurrent modification happened to the Cat meanwhile. If it has been modified, we notify the user or simply overwrite it (various possible strategies here). This is called an "application transaction with versioning".
Each database transaction, A and B, uses a new Session. Once the Cat is loaded and sent to the UI, it is "detached" from the Session and doesn't know anything about the Session. The Session is closed and there is no way to "notify" other Sessions about a change.
This scenario is also covered in the reference documentation.
You may also use a notify/observer pattern to achieve what you want, but this is even more complex. The concept of detached objects is nothing new for Hibernate (more than 1 year old feature), but it seems Java developers need some time to grasp the power of it. Even the Cocobase guys market it now as a cool new feature with the "sessionless persistence" buzzword.
_________________ JAVA PERSISTENCE WITH HIBERNATE http://jpwh.org Get the book, training, and consulting for your Hibernate team.
|