Thursday, July 16, 2009

OpenJpa Optimistic locking issue

In one of my project, the entity object is detached and sent to the rich client (eclipse rcp). Any operation on the client UI affects the detached object right away.  For example, there is a Boolean field on the entity object. The original value is true, and the user changes it to false on the UI. It changes the value in the object right away and the detached object is marked as “dirty”. But before the user save the change, he changes his mind and changes it back to true. But the detached object is still marked as “dirty”. When the object is going to be updated, openjpa finds that field is dirty and assumes that value is changed. Openjpa compares that value with the one in database and expect they are different but it gets the same value so that openjpa assumes some other transaction already changed the value in database and throws out the optimistic locking exception.

No comments:

Post a Comment