Hi,
if Id = 0 I got
javax.persistence.EntityExistsException: com.objectdb.o.UserException: Attempt to reuse an existing primary key value (ru.dz.train.test.ZeroIdTest$MyEntity:0)
if Id=1 no exception
code :
import javax.persistence.*; public class ZeroIdTest { public static void main(String[] args) { EntityManagerFactory emf = Persistence .createEntityManagerFactory("objectdb:$objectdb/db/test.tmp;drop"); EntityManager em = emf.createEntityManager(); final int Id = 0; em.getTransaction().begin(); em.persist(new MyEntity(Id)); em.getTransaction().commit(); em.getTransaction().begin(); em.merge(new MyEntity(Id)); em.getTransaction().commit(); em.close(); emf.close(); } @Entity public static class MyEntity { @Id private int Id; public MyEntity(int id) { Id = id; } public MyEntity() { } }