Hi,
I am developing an application using Java POJO and Hibernate at the backend, and a rich client at the front end. Communication between backend and frontend will be XML-based through a servlet, and based on primitive values (integer ids, strings etc). It is not possible to store java objects natively on the client.
I am not interested in pessimistic locking, and currently using optimistic locking with hibernate managed versioning.
I think I have understood almost all the concept mentined in 8.2 Implementing Application Transactions of Hibernate in Action. However, I did not get the practical way of storing the detached instance in a user's session. In 8.2.3 of Hibernate in Action, "Suppose we kept the Item as a detached instance, storing it in the user’s HTTP session, for example. We could reuse it in the second database transaction by reassociating it with the new Hibernate session using either lock() or update()." OK, since I am implementing the session management myself, I can manage a session storage per user, but when to put and remove objects from there ?
A simple example, suppose we have an addressbook.
User is in a need to update a person's details.
As I understood from 8.2. a request for a need for updating the person must put that person object into somewhere (session storage) I can later find for version checking (reattaching to the session).
When I actually update the person, I must first reattach the person object I stored before, and update its fields, and try to save it, and see if everything goes fine, or not.
Will I remove it from session storage after I managed to save it successfully ?
Suppose I transfer all the addressbook data to rich client, it does not communicate until update actually occurs. So I do not know when to store which object into session storage.
I think I am a little confused. Any help is really welcomed...
Thanks in advance.
MB
|