I am giving a detailed explanation of the application flow I have in my application. I am working on a Database viewer application. User can see all the records (rows) in my DB with this application and can edit from UI. This application is working fine. Now I want to implement Optimistic Locking for that I have created a version field in DB. Now I struck with a design issue,
Until now in my application, when a user view the record and want to edit it, in my controller method I am doing a Hibernate load and displaying the result in edit JSP page. Now when a user clicks 'Save' on the page I have to do save the record. Because it is a very complex entity, I am re populating this entity from DB and making the changes and doing Hibernate save or update.
Now, I want to implement versioning, so I no longer want to re populate the entity before I do save or update. Somehow I want to keep my complex entity safe and use this when I want to update. JSP hidden form fields are not possible in my case. Where can I keep my entity safe until user clicks 'Save' button and use it to persist in db ?. What are the possible and best approaches.
Update:
I have reviewed various posts in internet and planning to implement EHcache framework.