OpenJPA
  1. OpenJPA
  2. OPENJPA-1028

ClassCastException during findBy when embeddable is involved

    Details

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

      Description

      Caused by: java.lang.ClassCastException: myFvt.EmbedA incompatible with myFvt.EntityA
      at myFvt.EntityB.pcReplaceField(EntityB.java)
      at org.apache.openjpa.kernel.StateManagerImpl.replaceField(StateManagerImpl.java:3083)
      at org.apache.openjpa.kernel.StateManagerImpl.storeObjectField(StateManagerImpl.java:2512)
      at org.apache.openjpa.kernel.StateManagerImpl.storeObject(StateManagerImpl.java:2502)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.setMappedBy(JDBCStoreManager.java:453)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:384)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:289)
      at org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:111)
      at org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57)
      at org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:995)
      at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:953)

      This ClassCastException occurred in the following test scenario:

      (1)
      @Entity
      public class EntityA implements Serializable

      { @Id Integer id; @Embedded EmbedA embedA; ... }

      (2)
      @Embeddable
      public class EmbedA

      { @OneToOne(mappedBy="a", fetch = FetchType.EAGER, cascade = CascadeType.ALL) EntityB entityB; ... }

      (3)
      @Entity
      public class EntityB

      { @Id protected int id; @OneToOne private EntityA a; ... }

      (4) test case:
      EntityManager em = emf.createEntityManager();
      EntityA a = em.find(EntityA.class, 1);

        Activity

        Hide
        Pinaki Poddar added a comment -

        Is this mapping consistent?

        EmbedA says
        @OneToOne(mappedBy="a", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
        EntityB entityB;

        But EntityB declares its field 'a' as EntityA not as EmbedA
        @OneToOne
        private EntityA a;

        Show
        Pinaki Poddar added a comment - Is this mapping consistent? EmbedA says @OneToOne(mappedBy="a", fetch = FetchType.EAGER, cascade = CascadeType.ALL) EntityB entityB; But EntityB declares its field 'a' as EntityA not as EmbedA @OneToOne private EntityA a;
        Hide
        Thomas O Rowe added a comment -

        Successfully verified on RHEL 5.1 AMD64 w/ IBM SE6.

        Show
        Thomas O Rowe added a comment - Successfully verified on RHEL 5.1 AMD64 w/ IBM SE6.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development