I'm wondering how to handle optimistic lock version property in entity class using JPA (toplink essentials) from server to client and vice versa.
Here is the scenario.
From browser user send request to the server asking for individual user info to edit.
Server processes the request and return the result to the browser. The server code looks something like:
EntityManager em = EmProvider.getInstance().getEntityManagerFactory().createEntityManager();
User u = (User)em.find(User.class, myUserId);
return u; //response back to the browser
Here, my confusion is User table has "version"
column for optimistic locking
.
That means value of version field is also sent back to the client even though the client (me or anyone) would never use it. The version field is to be used in server side code.
So is it correct to send version number to client? Because otherwise I can't figure out how to check version number in case user clicks on "UPDATE" button on web page with modified data.
Please let me know if you need more clarification.