openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pinaki Poddar (JIRA)" <j...@apache.org>
Subject [jira] Commented: (OPENJPA-1028) ClassCastException during findBy when embeddable is involved
Date Wed, 08 Apr 2009 10:56:13 GMT

    [ https://issues.apache.org/jira/browse/OPENJPA-1028?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12696975#action_12696975
] 

Pinaki Poddar commented on OPENJPA-1028:
----------------------------------------

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; 

> ClassCastException during findBy when embeddable is involved
> ------------------------------------------------------------
>
>                 Key: OPENJPA-1028
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1028
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0
>            Reporter: Fay Wang
>            Assignee: Fay Wang
>
> 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);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message