Reputation: 2416
I have a web application implemented in JSF and JPA. In the UI, the users can updated a bunch of different entities before choosing to "save" the entire operation. During the save operation, if two users were crossing data, one of them is going to get an optimistic lock exception, which is all fine and dandy. However, I want to be able to tell which specific entity caused the Optimistic Lock exception while handling the exception in order to show a marker on the proper row in the UI. Using eclipselink, in the catch block for the optimisitc lock exception, is there a way to identify the entity which caused the optimistic lock exception?
Upvotes: 1
Views: 2549
Reputation: 18379
The JPA OptimisticLockException has a getEntity() method that returns the object that caused the lock error. EclipseLink's OptimisticLockException which is the caused by of the JPA exception also has a getObject() method.
Upvotes: 4