草庐IT

existingStore

全部标签

java - 使用 JPA merge() 时出现 OptimisticLockException

我有一个休息应用程序,其中一个资源可以更新。以下是负责完成此任务的两种方法:updateWithRelatedEntities(String,Store):接收id和通过反序列化PUT请求实体构建的新对象Store,在新对象上设置版本(用于乐观锁定)并调用更新在交易中。publicStoreupdateWithRelatedEntities(Stringid,StorenewStore){StoreexistingStore=this.get(id);newStore.setVersion(existingStore.getVersion());em.getTransaction().