Community
Participate
Working Groups
>Problem: If we add a plain java class as the root of an inheritance hierarchy - we fail on initialization with an IAException >The IAE is because we are using .managedType() internally and do not handle a BasicType at the root >Test model is extended by adding [Gear] at the top >Gear (non-entity/non-mappedSuperclass plain java class - non-persistable) +-----HockeyGear (Abstract Entity) (not cacheable) +----- GoalieGear (Concrete MappedSuperclass) --- (no cache entry) +----- Chest Protector (Concrete Entity) ---- cacheable +----- Pads (Concrete Entity) ---- cacheable >we fail here public <X> ManagedType<X> managedType(Class<X> clazz) { Object aType = this.managedTypes.get(clazz); // Throw an IAE exception if the returned type is not a ManagedType // For any clazz that resolves to a BasicType - use getType(clazz) in implementations when you are expecting a BasicType if(null != aType && aType instanceof ManagedType) { return (ManagedType<X>) aType; } else { > throw new IllegalArgumentException(ExceptionLocalization.buildMessage( "metamodel_class_incorrect_type_instance", new Object[] { clazz, "ManagedType", aType})); } } >with [EL Finest]: ServerSession(17102073)--Thread(Thread[Thread-4,6,main])--Initialization of the metamodel failed during deployment. Ignoring exception: [The type [null] is not the expected [ManagedType] for the key class [class org.eclipse.persistence.testing.models.jpa.advanced.fetchgroup.Gear].] Thread [Thread-4] (Suspended (breakpoint at line 425 in MetamodelImpl)) MetamodelImpl.managedType(Class<X>) line: 425 EntityTypeImpl<X>(ManagedTypeImpl<X>).getManagedSuperType() line: 761 EntityTypeImpl<X>(ManagedTypeImpl<X>).isAttributeDeclaredOnlyInLeafType(String, Attribute) line: 1057 MappedSuperclassTypeImpl<X>(ManagedTypeImpl<X>).isAttributeDeclaredOnlyInLeafType(String, Attribute) line: 1083 EntityTypeImpl<X>(ManagedTypeImpl<X>).isAttributeDeclaredOnlyInLeafType(String, Attribute) line: 1083 EntityTypeImpl<X>(ManagedTypeImpl<X>).isAttributeDeclaredOnlyInLeafType(String) line: 1005 EntityTypeImpl<X>(ManagedTypeImpl<X>).getDeclaredAttributes() line: 320 EntityManagerSetupImpl.initializeCanonicalMetamodel(Metamodel) line: 2020 EntityManagerSetupImpl.getMetamodel() line: 1998 EntityManagerSetupImpl.deploy(ClassLoader, Map) line: 398 EntityManagerFactoryImpl.getServerSession() line: 157 EntityManagerFactoryImpl.createEntityManagerImpl(Map) line: 214 EntityManagerFactoryImpl.createEntityManager() line: 202 JUnitTestCase.getServerSession() line: 365 JUnitTestCase.clearCache() line: 228 AdvancedJPAJunitTest.setUp() line: 107 >using aSuperType = (ManagedTypeImpl<?>)this.getMetamodel().managedType(aSuperClass); >we should be using aNonManagedSuperType = this.getMetamodel().getType(aSuperClass);
>blocks main metamodel bug# 266912 (finished) >blocks cache API bug (because of the pojo root at the extended test model)
>this breaks all Criteria API users that have a model where an Entity or MappedSuperclass inherit from a BasicType >predeploy succeeds >em.getMetamodel() fails
Created attachment 170725 [details] Handle BasicType as JPA inheritance superclass of Metamodel ManagedType
Created attachment 170738 [details] Handle BasicType as JPA inheritance superclass of Metamodel ManagedType
>see SVN rev# 7444 with test results http://fisheye2.atlassian.com/changelog/eclipselink/?cs=7444
>see additional future expansion of metamodel test model with BasicType inheritance root http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/metamodel_api#Mapped_Superclass_Test_Model
*** Bug 302606 has been marked as a duplicate of this bug. ***
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink