474 words

Removing an entity throws exception

#1
2011-06-08 14:02

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

anaq
anaq's picture
Joined on 2011-06-08
User Post #1
#2
2011-06-08 17:50

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
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #344
#3
2011-06-08 19:55

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

anaq
anaq's picture
Joined on 2011-06-08
User Post #2
#4
2011-06-08 22:50

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
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #345
#5
2011-06-09 02:21

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
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #348
#6
2011-06-09 06:35

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

 

Thank you

anaq
anaq's picture
Joined on 2011-06-08
User Post #4

Post Reply

Please read carefully the posting instructions - before posting to the ObjectDB website.

  • You may have to disable pop up blocking in order to use the toolbar (e.g. in Chrome).
  • Use ctrl + right click to open the browser context menu in the editing area (e.g. for using a browser spell checker).
  • To insert formatted lines (e.g. Java code, stack trace) - select a style in the toolbar and then insert the text in the new created block.
  • Avoid overflow of published source code examples by breaking long lines.
  • You may mark in paragraph code words (e.g. class names) with the code style (can be applied by ctrl + D).
  • Long stack traces (> 50 lines) and complex source examples (> 100 lines) should be posted as attachments.
Attachments:
Maximum file size: 32 MB
Cancel