ObjectDB ObjectDB

Removing an entity throws exception

#1

Hi all,

I'm testing ObjectDB for my project, but I have troubles with it. At this time I'm not able to remove customer entity, when it's read by a query (it's attached), it throws this exception:

Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException:

com.objectdb.o._RollbackException: Failed to commit transaction: 51

...

Caused by: com.objectdb.o._RollbackException: Failed to commit transaction: 51
at com.objectdb.o.JPE.g(JPE.java:89)
at com.objectdb.o.ERR.f(ERR.java:59)
at com.objectdb.o.OBC.onObjectDBError(OBC.java:1451)
at com.objectdb.jpa.EMImpl.commit(EMImpl.java:277)
... 39 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 51
at com.objectdb.o.BYR.A(BYR.java:892)
at com.objectdb.o.BYR.A(BYR.java:207)
at com.objectdb.o.VUT.l(VUT.java:703)
at com.objectdb.o.UML.o(UML.java:312)
at com.objectdb.o.ENT.X(ENT.java:872)
at com.objectdb.o.STA.P(STA.java:458)
at com.objectdb.o.STM.E(STM.java:433)
at com.objectdb.o.OBM.bG(OBM.java:781)
at com.objectdb.o.OBM.bE(OBM.java:715)
at com.objectdb.jpa.EMImpl.commit(EMImpl.java:274)
... 40 more

 

After this exception is the entity detached (why?). When I merge it, I can remove it without problems...

The Customer class code:


@Entity
public class Customer implements Serializable {
   
    private static final long serialVersionUID = 1L;

    @Id @GeneratedValue
    private Long id;
   
    private String name;
    private String surname;
   
    @OneToOne(cascade=CascadeType.ALL, fetch=FetchType.EAGER,
              optional=false, orphanRemoval=true)
    private Address address;
   
    @OneToMany(mappedBy = "customer", fetch= FetchType.LAZY)
    private List<Item> itemList;
   
    @OneToMany(mappedBy = "customer", fetch= FetchType.LAZY)
    private List<OtherItem> otherItemList;

    ... getters and setters

}

Only address is filled, itemList and otherItemList are empty.

The query:

em.createQuery("select c from Customer c").getResultList();

Code for removing:

    em.getTransaction().begin();
    try {
       //c = em.merge(c);
       em.remove(c);
       em.getTransaction().commit();
    }
    catch (Exception e) {
       em.getTransaction().rollback();
       throw new RuntimeException(e);
    }

My env: Netbeans 7, Java 1.6.24, ObjectDB 2.2.6_02 (same result with 2.2.5)

What does the exception mean? Where is the mistake?

Thank you

Michael

edit
delete
#2

It seems as an internal ObjectDB bug.

Please try build 2.2.6_03 that may fix this exception.

If you still get the exception - it would help if you could upload a test case that demonstrates it.

ObjectDB Support
edit
delete
#3

Thank you for fast response.

The fix changed the number 51 to 34. But it looks like my db was corrupted, because when I tried to create new project as a test case for this bug, with new empty db it works correctly. The objectdb doctor analysis has not found an error. Clearing the old database from all data helps, now it works.

Michael

edit
delete
#4

It seems that the bug that your test demonstrates cannot cause a corrupted database.

The problem was the result of comparing object images (used mainly to detected changes when enhancement is not in use) - after schema evolution.

Therefore, starting with a new database file could solve the problem even with no fix, since the schema changes are gone.

So either the bug is not completely fixed, or you still saw it with version 2.2.6_02 because of other reasons (e.g. cache of older ObjectDB jar file by the IDE, etc.)

ObjectDB Support
edit
delete
#5

The fix was indeed incomplete. Build 2.2.6_05 covers an additional case.

If you still have the old database please check it with this new fix.

 

ObjectDB Support
edit
delete
#6

Build 2.2.6_05 fixed it completly. I tested the old database and no exception was thrown.

 

Thank you

edit
delete

Reply

To post on this website please sign in.