0

I have to make a composite key in my spring boot service, using two columns (floorid & ticketid) from an existing table to prevent duplicate records.

But suddenly I get the following error when the save call is made:

Error is identifier of an instance of com.ge.current.digitaltwin.devicemap.entity.DeviceMapCompEntity was altered from com.ge.current.digitaltwin.devicemap.entity.DeviceMapId@3f3b65f9 to com.ge.current.digitaltwin.devicemap.entity.DeviceMapId@91bc6f2; nested exception is org.hibernate.HibernateException: identifier of an instance of com.ge.current.digitaltwin.devicemap.entity.DeviceMapCompEntity was altered from com.ge.current.digitaltwin.devicemap.entity.DeviceMapId@3f3b65f9 to com.ge.current.digitaltwin.devicemap.entity.DeviceMapId@.

Is there another way to prevent duplicate records without changing the code and bymaking some changes in backend?

I don't know what is happening. Can anybody help me on this?

g00glen00b
  • 41,995
  • 13
  • 95
  • 133
Kevin
  • 1
  • 1
    Please share the relevant code you have so far. What I can tell from the error is that you're trying to change the `floorid` or the `ticketid` of that record. Is that correct? – g00glen00b Apr 24 '19 at 06:32
  • Possible duplicate of [Hibernate: How to fix "identifier of an instance altered from X to Y"?](https://stackoverflow.com/questions/4179166/hibernate-how-to-fix-identifier-of-an-instance-altered-from-x-to-y) – Ancoron Apr 24 '19 at 06:59
  • Please compare the actual contents of the `DeviceMapId` instances (or implement `toString()` to make them visible when this error happens). – Ancoron Apr 24 '19 at 07:01
  • Possible duplicate of https://stackoverflow.com/questions/28231818/idclass-produces-identifier-of-an-instance-was-altered-with-jpa-and-hibernate – Ancoron Apr 24 '19 at 07:01

0 Answers0