This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 322166 - JPA2: Metamodel initialization of BasicCollection using parameterized generics fails to find member at current inheritance level
Summary: JPA2: Metamodel initialization of BasicCollection using parameterized generic...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P2 major (vote)
Target Milestone: ---   Edit
Assignee: Michael OBrien CLA
QA Contact:
URL: http://wiki.eclipse.org/EclipseLink/D...
Whiteboard:
Keywords:
Depends on: 266912 297928 322585
Blocks: 322184 303063
  Show dependency tree
 
Reported: 2010-08-09 13:39 EDT by Michael OBrien CLA
Modified: 2022-06-09 10:05 EDT (History)
1 user (show)

See Also:


Attachments
Collection attributes that are not inherited (exist on current type) that used to cause NPE on metamodel initialization now do reflection only on current class (3.71 KB, patch)
2010-08-09 13:58 EDT, Michael OBrien CLA
no flags Details | Diff
Collection attributes that are not inherited (exist on current type) that used to cause NPE on metamodel initialization now do reflection only on current class (17.90 KB, patch)
2010-09-09 15:48 EDT, Michael OBrien CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael OBrien CLA 2010-08-09 13:39:25 EDT
>In the following model we fail to properly find an attribute because we fail to do 
>secondary processing when the attribute is not inherited

>reproduction (add a getMetamodel() to JavaSECMPInitializer.initPersistenceUnits():262
Do a getMetamodel during deploy of the following model

descriptor	RelationalDescriptor  (id=346)	
	alias	"" (id=57)	
	javaClass	Class<T> (org.eclipse.persistence.testing.models.jpa.inherited.RatedBeerConsumer) (id=348)	
	javaClassName	"org.eclipse.persistence.testing.models.jpa.inherited.RatedBeerConsumer" (id=393)	

@MappedSuperclass
@Access(FIELD)
public abstract class RatedBeerConsumer<X, Y, Z> extends BeerConsumer<String> {
    @BasicCollection(valueColumn=@Column(name="ACCLAIM"))
    private Collection<X> acclaims;


Testing Browser (JPA) [Java Application]	
	org.eclipse.persistence.testing.framework.ui.TestingBrowserFrame at localhost:59678	
		Thread [main] (Suspended)	
			MappedSuperclassTypeImpl<X>(ManagedTypeImpl<X>).initialize() line: 1182	
			MetamodelImpl.initialize() line: 434	
			MetamodelImpl.<init>(DatabaseSession) line: 109	
			MetamodelImpl.<init>(EntityManagerSetupImpl) line: 128	
			EntityManagerSetupImpl.getMetamodel() line: 2003	
			JavaSECMPInitializer.initPersistenceUnits(Archive, Map, PersistenceInitializationHelper) line: 262	
			JavaSECMPInitializer.initialize(Map) line: 216	
			JavaSECMPInitializer.initializeFromAgent(Instrumentation) line: 159	

>stacktrace
Caused by: java.lang.NullPointerException
	at org.eclipse.persistence.internal.jpa.metamodel.ManagedTypeImpl.initialize(ManagedTypeImpl.java:1182)
	at org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.initialize(MetamodelImpl.java:434)
	at org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.<init>(MetamodelImpl.java:109)
	at org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.<init>(MetamodelImpl.java:128)
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.getMetamodel(EntityManagerSetupImpl.java:2003)
	at org.eclipse.persistence.internal.jpa.deployment.JavaSECMPInitializer.initPersistenceUnits(JavaSECMPInitializer.java:262)
	at org.eclipse.persistence.internal.jpa.deployment.JavaSECMPInitializer.initialize(JavaSECMPInitializer.java:216)
	at org.eclipse.persistence.internal.jpa.deployment.JavaSECMPInitializer.initializeFromAgent(JavaSECMPInitializer.java:159)
	... 12 more

>cause
ManagedTypeImpl.initialize():1182 fails to check for a null inheritingTypeMember before attempting to get a an attributeField from it


>fix
If the attribute is not found in the hierarchy above the current ManagedType using getMemberFromInheritingType() - then don't attempt to access the attribute field.
Instead defer to later code that calls various field/property method calls directly on the current class (ManagedType) in getTypeClassFromAttributeOrMethodLevelAccessor()
Comment 2 Michael OBrien CLA 2010-08-09 13:54:24 EDT
>fix essentially was not to do reflection on inherited class when the method does not exist there - for collection mappings

Testing Browser (JPA) [Java Application]	
	org.eclipse.persistence.testing.framework.ui.TestingBrowserFrame at localhost:60335	
		Thread [main] (Suspended)	
			MappedSuperclassTypeImpl<X>(ManagedTypeImpl<X>).getTypeClassFromAttributeOrMethodLevelAccessor(DatabaseMapping) line: 1365	
			MappedSuperclassTypeImpl<X>(ManagedTypeImpl<X>).initialize() line: 1195	
			MetamodelImpl.initialize() line: 434	
			MetamodelImpl.<init>(DatabaseSession) line: 109	
			MetamodelImpl.<init>(EntityManagerSetupImpl) line: 128	
			EntityManagerSetupImpl.getMetamodel() line: 2003	
			JavaSECMPInitializer.initPersistenceUnits(Archive, Map, PersistenceInitializationHelper) line: 262	
			JavaSECMPInitializer.initialize(Map) line: 216	

>aField	Field  (id=153)	
	clazz	Class<T> (org.eclipse.persistence.testing.models.jpa.inherited.RatedBeerConsumer) (id=65)	
	name	"acclaims" (id=161)	
	type	Class<T> (java.util.Collection) (id=78)	
aType	Class<T> (java.util.Collection) (id=78)
Comment 3 Michael OBrien CLA 2010-08-09 13:58:32 EDT
Created attachment 176173 [details]
Collection attributes that are not inherited (exist on current type) that used to cause NPE on metamodel initialization now do reflection only on current class

Collection attributes that are not inherited (exist on current type) that used to cause NPE on metamodel initialization now do reflection only on current class
Comment 4 Michael OBrien CLA 2010-08-09 14:10:10 EDT
>Reviewed by Guy P.
Comment 5 Michael OBrien CLA 2010-09-09 15:48:15 EDT
Created attachment 178560 [details]
Collection attributes that are not inherited (exist on current type) that used to cause NPE on metamodel initialization now do reflection only on current class
Comment 6 Michael OBrien CLA 2010-09-13 10:51:23 EDT
>see SVN rev# 8158 for 2.2
https://fisheye2.atlassian.com/changelog/eclipselink/?cs=8158
Comment 7 Eclipse Webmaster CLA 2022-06-09 10:05:48 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink