Merge an entity, change its id, merge again, cause “mapped to a primary key column in the database. Updates are not allowed” error

前端 未结 4 1193
一整个雨季
一整个雨季 2021-02-14 12:22

I have a JPA program where EclipseLink is the Persistence provider. When I merge an user entity, change its ID, and try to merge the same user instance again, an error is thrown

4条回答
  •  醉梦人生
    2021-02-14 12:48

    It seems to be an bug of EclipseLink. I have changed the persistence provider from EclipseLink to Hibernate:

    from

    org.eclipse.persistence.jpa.PersistenceProvider
    

    to

    org.hibernate.ejb.HibernatePersistence  
    

    No error has been thrown.

    The version of EclipseLink is 2.3.2. (which is shipped with the latest Glassfish application server 3.1.2).

    The version of hibernate is, as of now the latest, 4.1.7.

提交回复
热议问题