Failed to commit transaction: Attempt to reuse an existing primary key value (613)


I am using ObjectDB 2.8.3 version for my University Project which currently i am trying to inplement an Integration testing to one of my DataAccess methods. But, the problem comes before i try the method i want to be proved, exactly when i try to set up the database. These one is the test method.

    public void testONA() {
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
            Date oneDate=null;
            ap= new ArrayList<Pronostikoa>();
            try {
                oneDate = sdf.parse("05/10/2022");
            } catch (ParseException e) {
                // TODO Auto-generated catch block
            bez=testBL.addBezeroa("Jon", "Smith", "Clark", "SmithClark", "ClarkSmith", "123456789", "",
                    new Date(2001, 8, 1));
            ev=testBL.addEventWithQuestion("event1", oneDate, "question1", 2);
            pronos=testBL.addPronostikoatoQuestion(q, "pronostic1", 2);
            bez=testBL.addApustua(ap, 4, bez);
            apu=testBL.getBezeroApustu(bez, ap);
            System.out.println(testBL.getBezeroApustu(bez, ap));
        }catch(Exception e) {
        }finally {

The problem comes when i do the call testBL.addApustua() method, where it throws this error and with e.printStackTrace i try to figure where is the problem. 

[ObjectDB 2.8.3] javax.persistence.RollbackException
Failed to commit transaction: Attempt to reuse an existing primary key value (domain.Pronostikoa:72) (error 613)
    at com.objectdb.jpa.EMImpl.commit(
    at test.dataAccess.TestDataAccess.addApustua(
    at test.businessLogic.TestFacadeImplementation.addApustua(
    at DeleteApustuaInt.testONA(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(
    at org.junit.runners.ParentRunner$3.evaluate(
    at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(
    at org.junit.runners.ParentRunner.runLeaf(
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(
    at org.junit.runners.ParentRunner$
    at org.junit.runners.ParentRunner$1.schedule(
    at org.junit.runners.ParentRunner.runChildren(
    at org.junit.runners.ParentRunner.access$100(
    at org.junit.runners.ParentRunner$2.evaluate(
    at org.junit.internal.runners.statements.RunBefores.evaluate(
    at org.junit.runners.ParentRunner$3.evaluate(
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
Caused by: javax.persistence.EntityExistsException: com.objectdb.o.UserException: Attempt to reuse an existing primary key value (domain.Pronostikoa:72)
    at com.objectdb.o._EntityExistsException.a(
    at com.objectdb.o.JPE.d(
    at com.objectdb.o.JPE.d(
    ... 33 more


The problem it tolds to me is that when i try to create a class (Apustua) which contains other class objects list (ArrayList<Pronostikoa>)  i don´t know why the ID used to create it is the same as it has the Pronostikoa object , which could not be the same theoricaly i think cause in both cases the @Id in the database is @GeneratedValue, and at the commit clause it throws the exception. If you could explain to me why is it happening  i would be grateful with you cause i am having this problem for 2-3 weeks and on Internet there is no information about it. 


I know that maybe my explanation is not the best one, in that case tell to me and i will try to explane it better.


Assuming the error message is correct - you are trying to store more than one object in the database with the same primary key.

Unfortunately it is impossible to provide help based on this report and the fragment of code, which do not include the relevant information regarding the exception.

To explore this issue further you will have to provide a minimal runnable program in a one file format, which demonstrates the issue.

ObjectDB Support