Community
Participate
Working Groups
Have the following model: @Entity public class Employee { @Id private int id; @Embedded private ContactInfo contactInfo; //... } @Embeddable @Access(AccessType.FIELD) public class ContactInfo { @Embedded private Address residence; @ManyToOne private Phone primaryPhone; @ManyToMany @MapKey(name = "type") private Map<String, Phone> phones; //... } @Embeddable @Access(AccessType.FIELD) public class Address { private String street; private String city; private String state; //... } @Entity public class Phone { @Id String num; @ManyToMany(mappedBy = "contactInfo.phones") List<Employee> employees; String type; //... } Get the following exception when trying to deploy: [exec] Caused by: java.lang.ClassCastException: org.eclipse.persistence.internal.jpa.metamodel.EmbeddableTypeImpl cannot be cast to org.eclipse.persistence.internal.jpa.metamodel.IdentifiableTypeImpl [exec] at org.eclipse.persistence.internal.jpa.metamodel.ManagedTypeImpl.initialize(ManagedTypeImpl.java:1152) [exec] at org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.initialize(MetamodelImpl.java:399) [exec] at org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.<init>(MetamodelImpl.java:101) [exec] at org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.<init>(MetamodelImpl.java:120) [exec] at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.getMetamodel(EntityManagerSetupImpl.java:1939) [exec] at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:385) [exec] ... 58 more
>Model @Inheritance(strategy=JOINED) @Entity(name="GalacticMetamodel") @Table(name="CMP3_MM_GALACTIC") @Access(AccessType.FIELD) // for 316991 /** * Note that this Entity inherits from a Transient superclass (a non-entity, non-mappedSuperclass) * The Position class will be a BasicType (with no attributes outside of its Java class). * The Metamodel API will therefore not allow inheritance of any attributes into subclasses. * Any attempt to access attributes of Position via GalacticPosition will get an expected IAE. */ public class GalacticPosition extends Position implements java.io.Serializable { private static final long serialVersionUID = 1395818966377137158L; // Any reference to this embedded key requires a bidirectional relationship (not unidirectional) @EmbeddedId @Column(name="GALACTIC_ID") protected EmbeddedPK primaryKey; @Embedded private Observation observation; ...} @Embeddable public class Observation { // This class is embedded inside a GalacticPosition // nested embeddable @Embedded private ObservationDetail detail; ...} @Embeddable public class ObservationDetail { private String data; ...}
>Nested embeddables initalize OK and pass through Metatdata and Metamodel processing in predeploy() >after a full predeploy/deploy we set the root of the nested embeddable on the EntityType this EntityTypeImpl<X> (id=425) descriptor RelationalDescriptor (id=439) javaClass Class<T> (org.eclipse.persistence.testing.models.jpa.metamodel.GalacticPosition) (id=440) members HashMap<K,V> (id=441) table HashMap$Entry<K,V>[16] (id=443) [3] HashMap$Entry<K,V> (id=447) key "observation" (id=450) value SingularAttributeImpl<X,T> (id=433) elementType EmbeddableTypeImpl<X> (id=130) managedType EntityTypeImpl<X> (id=425) mapping AggregateObjectMapping (id=434) >Later in our extended test case Thread [Thread-5] (Suspended) MetamodelMetamodelTest.testEmbeddableType() line: 1544 >We see that the Metamodel has been initialized property >The nested embeddable hierarchy exists on the ManagedType >in the embeddables map as a SingularAttribute on the EmbeddableType root metamodel MetamodelImpl (id=70) embeddables LinkedHashMap<K,V> (id=113) table HashMap$Entry<K,V>[16] (id=697) [4] LinkedHashMap$Entry<K,V> (id=699) key Class<T> (org.eclipse.persistence.testing.models.jpa.metamodel.Observation) (id=132) value EmbeddableTypeImpl<X> (id=130) javaClass Class<T> (org.eclipse.persistence.testing.models.jpa.metamodel.Observation) (id=132) members HashMap<K,V> (id=712) size 3 table HashMap$Entry<K,V>[16] (id=716) [2] HashMap$Entry<K,V> (id=719) key "detail" (id=722) value SingularAttributeImpl<X,T> (id=226) elementType EmbeddableTypeImpl<X> (id=160) descriptor RelationalDescriptor (id=159) javaClass Class<T> (org.eclipse.persistence.testing.models.jpa.metamodel.ObservationDetail) (id=161) managedType EmbeddableTypeImpl<X> (id=130) descriptor RelationalDescriptor (id=128) javaClass Class<T> (org.eclipse.persistence.testing.models.jpa.metamodel.Observation) (id=132) mapping AggregateObjectMapping (id=227) >and as a SingularAttribute on the EmbeddableType attribute on the managedType EntityType parent on the metamodel metamodel MetamodelImpl (id=70) entities LinkedHashMap<K,V> (id=118) size 17 [16] LinkedHashMap$Entry<K,V> (id=748) after LinkedHashMap$Entry<K,V> (id=765) key Class<T> (org.eclipse.persistence.testing.models.jpa.metamodel.GalacticPosition) (id=440) value EntityTypeImpl<X> (id=425) javaClass Class<T> (org.eclipse.persistence.testing.models.jpa.metamodel.GalacticPosition) (id=440) members HashMap<K,V> (id=441) size 5 table HashMap$Entry<K,V>[16] (id=443) [3] HashMap$Entry<K,V> (id=447) key "observation" (id=450) value SingularAttributeImpl<X,T> (id=433) elementType EmbeddableTypeImpl<X> (id=130) descriptor RelationalDescriptor (id=128) javaClass Class<T> (org.eclipse.persistence.testing.models.jpa.metamodel.Observation) (id=132) members HashMap<K,V> (id=712) size 3 table HashMap$Entry<K,V>[16] (id=716) [2] HashMap$Entry<K,V> (id=719) key "detail" (id=722) value SingularAttributeImpl<X,T> (id=226) elementType EmbeddableTypeImpl<X> (id=160) descriptor RelationalDescriptor (id=159) javaClass Class<T> (org.eclipse.persistence.testing.models.jpa.metamodel.ObservationDetail) (id=161) members HashMap<K,V> (id=609) metamodel MetamodelImpl (id=70) managedType EmbeddableTypeImpl<X> (id=130) descriptor RelationalDescriptor (id=128) javaClass Class<T> (org.eclipse.persistence.testing.models.jpa.metamodel.Observation) (id=132) members HashMap<K,V> (id=712) metamodel MetamodelImpl (id=70) mapping AggregateObjectMapping (id=227) managedType EntityTypeImpl<X> (id=425) mapping AggregateObjectMapping (id=434)
Created attachment 184182 [details] Metamodel : nested embeddable test model and case changes
>See test model additions in SVN rev# 8587 https://fisheye2.atlassian.com/changelog/eclipselink/?cs=8587 >Wiki models pending
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink