确定哪个实体导致乐观锁异常
我有一个用 JSF 和 JPA 实现的 Web 应用程序。在 UI 中,用户可以在选择“保存”整个操作之前更新一堆不同的实体。在保存操作期间,如果两个用户交叉数据,其中一个将获得乐观锁异常,这一切都很好。但是,我希望能够在处理异常时判断哪个特定实体导致了乐观锁异常,以便在 UI 中的正确行上显示标记。使用eclipselink,在乐观锁异常的catch块中,有没有办法识别导致乐观锁异常的实体?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
JPA OptimisticLockException 有一个 getEntity() 方法,该方法返回导致锁定错误的对象。由 JPA 异常引起的 EclipseLink 的 OptimisticLockException 也有一个 getObject() 方法。
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.