[英]Retrieve an object and save as new one with Hibernate/Spring Data JPA
In one of the services we perform some operations: 在其中一项服务中,我们执行一些操作:
Unfortunately, we are getting an error: "identifier of an instance of B_Object altered from X to Z". 不幸的是,我们收到一个错误:“ B_Object实例的标识符从X更改为Z”。 How we should do this in correct way?? 我们应该如何正确地做到这一点?
您应该像在新实体一样进行更改和存储之前,分离在第2点中获取的对象。
Erase the unique identifier from the object (if it's auto-generated) 从对象中删除唯一标识符(如果它是自动生成的)
If doesnt have a autogen key you need to remove the constraints for the composite key. 如果没有自动生成键,则需要删除组合键的约束。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.