OpenJPA
  1. OpenJPA
  2. OPENJPA-1256

get java.lang.ClassCastException when IdClass contains an Enum Field

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-M2
    • Fix Version/s: 2.0.0-M3
    • Component/s: kernel
    • Labels:
      None

      Description

      Suppose EntityA and EntityB are defined as follows:

      @Entity
      class EntityA

      { @Id int id; @OneToOne(fetch=fetchType=LAZE) EntityB entityB; ... }

      @Entity
      @IdClass(BId.class)
      class EntityB {

      @Id
      int intId;

      @Id
      BType bType;
      ...

      public enum BType

      { A1, A2, A3, A4 }

      ;
      ...
      }

      ClassCast Exception is thrown in the following situation:

      EntityA a = em.find(EntityA.class, 1)
      EntityB b = a.getEntityB();

        Activity

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        21h 23m 1 Fay Wang 20/Aug/09 19:28
        Resolved Resolved Closed Closed
        8s 1 Fay Wang 20/Aug/09 19:28
        Donald Woods made changes -
        Assignee Fay Wang [ faywang ]
        Fix Version/s 2.0.0-M3 [ 12314148 ]
        Fix Version/s 2.0.0 [ 12314019 ]
        Affects Version/s 2.0.0-M2 [ 12313483 ]
        Affects Version/s 2.0.0 [ 12314019 ]
        Fay Wang made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Fay Wang made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        Fay Wang added a comment -

        The specific ClassCastException is:

        java.lang.ClassCastException: BType cannot be cast to
        org.apache.openjpa.util.ObjectId

        test.EntityB.pcCopyKeyFieldsToObjectId(EntityB.java)
        org.apache.openjpa.enhance.PCRegistry.copyKeyFieldsToObjectId(PCRegistry.java:172)

        org.apache.openjpa.util.ApplicationIds.fromPKValues(ApplicationIds.java:219)

        org.apache.openjpa.jdbc.meta.ClassMapping.getObjectId(ClassMapping.java:216)

        org.apache.openjpa.jdbc.meta.ClassMapping.getObjectId(ClassMapping.java:147)

        org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:934)

        org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:280)

        org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2349)
        org.apache.openjpa.jdbc.meta.strats.RelationToManyInverseKeyFieldStrategy.loadElement(RelationToManyInverseKeyFieldStrategy.java:87)
        org.apache.openjpa.jdbc.meta.strats.StoreCollectionFieldStrategy.load(StoreCollectionFieldStrategy.java:554)
        org.apache.openjpa.jdbc.meta.FieldMapping.load(FieldMapping.java:919)

        org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:641)

        org.apache.openjpa.kernel.DelegatingStoreManager.load(DelegatingStoreManager.java:116)
        org.apache.openjpa.kernel.ROPStoreManager.load(ROPStoreManager.java:78)

        org.apache.openjpa.kernel.StateManagerImpl.loadFields(StateManagerImpl.java:3035)

        org.apache.openjpa.kernel.StateManagerImpl.loadField(StateManagerImpl.java:3113)

        org.apache.openjpa.kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:1606)

        Show
        Fay Wang added a comment - The specific ClassCastException is: java.lang.ClassCastException: BType cannot be cast to org.apache.openjpa.util.ObjectId test.EntityB.pcCopyKeyFieldsToObjectId(EntityB.java) org.apache.openjpa.enhance.PCRegistry.copyKeyFieldsToObjectId(PCRegistry.java:172) org.apache.openjpa.util.ApplicationIds.fromPKValues(ApplicationIds.java:219) org.apache.openjpa.jdbc.meta.ClassMapping.getObjectId(ClassMapping.java:216) org.apache.openjpa.jdbc.meta.ClassMapping.getObjectId(ClassMapping.java:147) org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:934) org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:280) org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2349) org.apache.openjpa.jdbc.meta.strats.RelationToManyInverseKeyFieldStrategy.loadElement(RelationToManyInverseKeyFieldStrategy.java:87) org.apache.openjpa.jdbc.meta.strats.StoreCollectionFieldStrategy.load(StoreCollectionFieldStrategy.java:554) org.apache.openjpa.jdbc.meta.FieldMapping.load(FieldMapping.java:919) org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:641) org.apache.openjpa.kernel.DelegatingStoreManager.load(DelegatingStoreManager.java:116) org.apache.openjpa.kernel.ROPStoreManager.load(ROPStoreManager.java:78) org.apache.openjpa.kernel.StateManagerImpl.loadFields(StateManagerImpl.java:3035) org.apache.openjpa.kernel.StateManagerImpl.loadField(StateManagerImpl.java:3113) org.apache.openjpa.kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:1606)
        Fay Wang created issue -

          People

          • Assignee:
            Fay Wang
            Reporter:
            Fay Wang
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development