Issue #852: JPA Composite Key make Object Db throws "Unexpected exception (Error 990)"

Type: Bug ReoprtVersion: 2.4.0Priority: NormalStatus: FixedReplies: 3
#1

Hello Object Db community :)

I am using this wonderful library and I caught a strange exception while testing the "composite key" feature in JPA.

Let's see what I am doing :

@Entity
public class Book {
    @EmbeddedId BookId id;
}

@Embeddable
Class BookId {
    Integer bookIdCountry;
    ECountry country;
}

My BookId contains 2 attributes:
One Integer and one enum.

These attributes are compliant with the object Db Documentation:
http://www.objectdb.com/java/jpa/entity/id

Unfortunately, while merging the entity, object db is throwing the following Exception :

[ObjectDB 2.4.0] Unexpected exception (Error 990)

My bookId and its attributes are NEVER null.

Have you any idea about this problem?

#####

Additionals infos, here is the stack trace :

[ObjectDB 2.4.0] Unexpected exception (Error 990)
     Generated by OpenJDK 64-Bit Server VM 1.6.0_18 (on Linux 2.6.32).
    Please report this error on http://www.objectdb.com/database/issue/new
    com.objectdb.o.InternalException: null
    com.objectdb.o.InternalException
     at com.objectdb.o.VUT.e(VUT.java:221)
     at com.objectdb.o.VUT.e(VUT.java:148)
     at com.objectdb.o.UMR.s(UMR.java:426)
     at com.objectdb.o.UMR.q(UMR.java:382)
     at com.objectdb.o.UML.s(UML.java:484)
     at com.objectdb.o.MMM.X(MMM.java:794)
     at com.objectdb.o.EMR.h(EMR.java:140)
     at com.objectdb.o.TVS.g(TVS.java:104)
     at com.objectdb.o.TVS.g(TVS.java:93)
     at com.objectdb.o.EMR.q(EMR.java:75)

The problem occurs on the VUT class on the call "e" method. A look at the bytecode show :

L219 to 221 : checkcast BigInteger

I don't know why this cast is made ... i haven't any BigInteger in my app.

Well, debugging obfuscated code is not easy for me.

Any help would be appreciated :)

#2

Can you please attach a small test that demonstrates the exception?

If you can use the format in the posting instructions it may be very helpful.

ObjectDB Support
#3

Well i have tested a small case test with minimal code, so i have pointed out the problem.  It's comes from the "enum" type which is not correctly taken into account by Object Db. When I replace EEnum type by an Integer, all is fine !

May the problem be reproduced with a simple ( not embedded Id ) key with an enum type.

Here is the code :

package test;

import java.util.*;
import javax.persistence.*;

public final class MyTestCase {

    @Entity
    public static class MyEntity {
        @EmbeddedId public MyEntityId id;
    }
    
    @Embeddable
    public static class MyEntityId {
        public EEnum enumeration;
    }
   
    public enum EEnum {
        FIRST,
        SECOND;
    }

    public static void main(String[] args)  {

        EntityManagerFactory emf =
            Persistence.createEntityManagerFactory(
                "objectdb:$objectdb/db/test.tmp;drop");

        EntityManager em = emf.createEntityManager();

        em.getTransaction().begin();
        MyEntity entity = new MyEntity();
        MyEntityId entityId = new MyEntityId();
       
        entityId.enumeration = EEnum.FIRST;
        entity.id = entityId;
       
        em.persist(entity);
        em.getTransaction().commit();

        Query query = em.createQuery("SELECT e FROM MyEntity e");
        List resultList = query.getResultList();
        System.out.println(resultList);

        em.close();
        emf.close();
    }
}

The stack trace follows :

Exception in thread "main" [ObjectDB 2.4.0] Unexpected exception (Error 990)
  Generated by Java HotSpot(TM) Client VM 1.6.0_32 (on Windows XP 5.1).
Please report this error on http://www.objectdb.com/database/issue/new
com.objectdb.o.InternalException: null
com.objectdb.o.InternalException
at com.objectdb.o.VUT.e(VUT.java:221)
at com.objectdb.o.VUT.e(VUT.java:148)
at com.objectdb.o.UMR.s(UMR.java:426)
at com.objectdb.o.UMR.q(UMR.java:382)
at com.objectdb.o.UML.s(UML.java:478)
at com.objectdb.o.MMM.X(MMM.java:794)
at com.objectdb.o.OBM.bx(OBM.java:387)
at com.objectdb.o.OBM.bx(OBM.java:252)
at com.objectdb.jpa.EMImpl.persist(EMImpl.java:375)
#4

Thank you for this report.

Please try build 2.4.1_06 that should fix this exception.

ObjectDB Support

Reply