ERROR Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)
javax.persistence.OptimisticLockException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) :
at org.hibernate.internal.ExceptionConverterImpl.wrapStaleStateException(ExceptionConverterImpl.java:223)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:93)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188)
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1395)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1378)
at jdk.internal.reflect.GeneratedMethodAccessor716.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:350)
at jdk.proxy2/jdk.proxy2.$Proxy213.flush(Unknown Source)
at jdk.internal.reflect.GeneratedMethodAccessor716.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:308)
at jdk.proxy2/jdk.proxy2.$Proxy213.flush(Unknown Source)
This is coming up when I try to save the object from UI the second time from the same application where I did a save first time (first time it does not throw this exception). This error does not go away until I restart my server. If I run my server on another machine this error does not come. So I am wondering if the problem is how db is setup on this machine but not exactly sure.
Looked at the logs and hibernate documentaion, also went through old stackoverflow questions.