Community
Participate
Working Groups
Build Identifier: 2.1.2 and 2.2.0 When calling EntitiyManager.getCriteriaBuilder() I get a ClassCastException: java.lang.ClassCastException: org.eclipse.persistence.internal.jpa.metamodel.EmbeddableTyp eImpl cannot be cast to javax.persistence.metamodel.IdentifiableType I tried EclipseLink 2.1.2 and 2.2.0, both the same behaviour. I also opened a thread in the forum: http://www.eclipse.org/forums/index.php?t=msg&goto=662474&S=68b3ab530f3d4764ae9fdd309273ce16 It may be possible that an entity is deriving from an embeddable - I haven't verified that yet. (Since I have a lot of entities I can't post the whole model here, sorry.) Anyway, the stacktraces (see forum) aren't very helpful. Reproducible: Always Steps to Reproduce: 1. emf = Persistence.createEntityManagerFactory(persistenceUnit, jpaProperties); 2. em = emf.createEntityManager(); 3. mm = em.getMetamodel(); OR cb = em.getCriteriaBuilder(); -> ClassCastException
Please post any information you can about the model. If we are unable to recreate, we will have to close this bug.
>A MappedSuperclass or Entity (Identifiable Types) cannot inherit from an Embeddable (a Managed Type) It seems that the superclass in the call below also needs to be checked with isIdentifiableType() >MetamodelImpl.initialize():429 - 2.3 trunk Class superclass = aClass.getSuperclass(); // explicitly set the superType to null (just in case it is initialized to a non-null value in a constructor) IdentifiableType<?> identifiableTypeSuperclass = null; if(potentialIdentifiableType.isIdentifiableType() && superclass != ClassConstants.OBJECT) { // Get the Entity or MappedSuperclass // A hierarchy of Entity --> Entity or Entity --> MappedSuperclass will be found > identifiableTypeSuperclass = (IdentifiableType<?>)managedTypes.get(superclass); The above code requires extra exception handling code attached, and should be added to DI 42 http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/metamodel_api#DI_42:_20090709:_IdentifiableType.supertype_-_what_do_top-level_types_set_it_to
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink