| Summary: | Dynamic JPA: Initialization of the metamodel will fail on FK ID initialization with JPADynamicEntities having to-many relationships | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | Frank Schwarz <fs5> | ||||||||
| Component: | Eclipselink | Assignee: | Michael OBrien <michael.f.obrien> | ||||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||||
| Severity: | major | ||||||||||
| Priority: | P3 | CC: | eclipselink.orm-inbox, michael.f.obrien, peter.krogh | ||||||||
| Version: | unspecified | ||||||||||
| Target Milestone: | --- | ||||||||||
| Hardware: | All | ||||||||||
| OS: | All | ||||||||||
| URL: | http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/metamodel_api#Design_Issues | ||||||||||
| Whiteboard: | |||||||||||
| Bug Depends on: | 266912 | ||||||||||
| Bug Blocks: | 325701, 325754, 297971 | ||||||||||
| Attachments: |
|
||||||||||
|
Description
Frank Schwarz
Created attachment 179214 [details]
testcase
Created attachment 179215 [details]
proposed patch
ManagedTypeImpl#initialize() needs a refactoring
>Initially, I see no NPE (this is before we could compile the following parameterized generic in a recent Dynamic API change) >However, this is because we are hiding the NPE which is visible during debugging only //Class<? extends DynamicEntity> employeeClass = helper.getType("Employee").getJavaClass(); Class employeeClass = helper.getType("Employee").getJavaClass(); [EL Finest]: 2010-09-19 15:19:56.004--ServerSession(12122157)--Thread(Thread[main,5,main])--Begin predeploying Persistence Unit virtualmodel; session file:/C:/wse/w35e/user.test.325699/bin/_virtualmodel_url=jdbc:derby://127.0.0.1:1527/weblogic;create=true_user=APP; state Initial; factoryCount 0 [EL Finest]: 2010-09-19 15:19:56.129--ServerSession(12122157)--Thread(Thread[main,5,main])--End predeploying Persistence Unit virtualmodel; session file:/C:/wse/w35e/user.test.325699/bin/_virtualmodel_url=jdbc:derby://127.0.0.1:1527/weblogic;create=true_user=APP; state Predeployed; factoryCount 1 [EL Finest]: 2010-09-19 15:19:56.144--ServerSession(12122157)--Thread(Thread[main,5,main])--Begin deploying Persistence Unit virtualmodel; session file:/C:/wse/w35e/user.test.325699/bin/_virtualmodel_url=jdbc:derby://127.0.0.1:1527/weblogic;create=true_user=APP; state Predeployed; factoryCount 1 [EL Info]: 2010-09-19 15:19:58.047--ServerSession(12122157)--Thread(Thread[main,5,main])--file:/C:/wse/w35e/user.test.325699/bin/_virtualmodel_url=jdbc:derby://127.0.0.1:1527/weblogic;create=true_user=APP login successful >However we do get an ignored exception in our catch-all that we should look at [EL Finest]: 2010-09-19 15:19:58.235--ServerSession(12122157)--Thread(Thread[main,5,main])--Initialization of the metamodel failed during deployment. Ignoring exception: [null] [EL Finest]: 2010-09-19 15:19:58.406--UnitOfWork(6131844)--Thread(Thread[main,5,main])--PERSIST operation called on: {Employee}. [EL Finest]: 2010-09-19 15:19:58.406--UnitOfWork(6131844)--Thread(Thread[main,5,main])--PERSIST operation called on: {Address}. [EL Finer]: 2010-09-19 15:19:58.406--UnitOfWork(6131844)--Thread(Thread[main,5,main])--begin unit of work commit [EL Finer]: 2010-09-19 15:19:58.422--ClientSession(4171180)--Connection(9800632)--Thread(Thread[main,5,main])--begin transaction [EL Finest]: 2010-09-19 15:19:58.422--UnitOfWork(6131844)--Thread(Thread[main,5,main])--Execute query InsertObjectQuery({Employee 67d93a32-ec56-45b3-a1d9-ae24cb39c8b1}) [EL Fine]: 2010-09-19 15:19:58.422--ClientSession(4171180)--Connection(9800632)--Thread(Thread[main,5,main])--INSERT INTO EMPLOYEE (ID, NAME) VALUES (?, ?) bind => [67d93a32-ec56-45b3-a1d9-ae24cb39c8b1, John Doe] [EL Finest]: 2010-09-19 15:19:58.437--UnitOfWork(6131844)--Thread(Thread[main,5,main])--Execute query InsertObjectQuery({Address f1e2fc62-eb04-4488-a5b3-49896d0651dd}) [EL Fine]: 2010-09-19 15:19:58.437--ClientSession(4171180)--Connection(9800632)--Thread(Thread[main,5,main])--INSERT INTO ADDRESS (ID, CITY) VALUES (?, ?) bind => [f1e2fc62-eb04-4488-a5b3-49896d0651dd, Pleasantville] [EL Finest]: 2010-09-19 15:19:58.437--UnitOfWork(6131844)--Thread(Thread[main,5,main])--Execute query DataModifyQuery() [EL Fine]: 2010-09-19 15:19:58.453--ClientSession(4171180)--Connection(9800632)--Thread(Thread[main,5,main])--UPDATE ADDRESS SET EMPLOYEE_ID = ? WHERE (ID = ?) bind => [67d93a32-ec56-45b3-a1d9-ae24cb39c8b1, f1e2fc62-eb04-4488-a5b3-49896d0651dd] [EL Finer]: 2010-09-19 15:19:58.656--ClientSession(4171180)--Connection(9800632)--Thread(Thread[main,5,main])--commit transaction [EL Finest]: 2010-09-19 15:19:59.28--ServerSession(12122157)--Thread(Thread[main,5,main])--Begin undeploying Persistence Unit virtualmodel; session file:/C:/wse/w35e/user.test.325699/bin/_virtualmodel_url=jdbc:derby://127.0.0.1:1527/weblogic;create=true_user=APP; state Deployed; factoryCount 1 >After an update to 8216 >I agree that initialize should be refactored, a slightly modified patch will be uploaded shortly that includes extra refactoring. >I see that the member field has not been initialized mapping UnidirectionalOneToManyMapping (id=151) attributeName "addresses" (id=161) member null >And after when we process Id's we assume Id attributes are set Thread [main] (Suspended (breakpoint at line 96 in IdentifiableTypeImpl)) EntityTypeImpl<X>(IdentifiableTypeImpl<X>).initializeIdAttributes() line: 96 MetamodelImpl.initialize() line: 440 MetamodelImpl.<init>(DatabaseSession) line: 109 MetamodelImpl.<init>(EntityManagerSetupImpl) line: 128 EntityManagerSetupImpl.getMetamodel() line: 2011 EntityManagerSetupImpl.deploy(ClassLoader, Map) line: 408 EntityManagerFactoryImpl.getServerSession() line: 164 JpaHelper.getServerSession(EntityManagerFactory) line: 161 VirtualModelTest.initializeEMF() line: 59 >The catchall exception handler is not printing out the real exception session.log(SessionLog.FINEST, SessionLog.METAMODEL, "metamodel_init_failed", new Object[]{e.getMessage()}); [EL Finest]: 2010-09-19 15:47:51.197--ServerSession(4347715)--Thread(Thread[main,5,main])--Initialization of the metamodel failed during deployment. Ignoring exception: [null] >Good fix on checking for the alternate class ValuesAccessor - the Id attribute of type List is getting picked up now. attribute ListAttributeImpl<X,V> (id=146) elementType EntityTypeImpl<X> (id=152) managedType EntityTypeImpl<X> (id=116) mapping UnidirectionalOneToManyMapping (id=122) addTargetQuery DataModifyQuery (id=137) attributeAccessor ValuesAccessor (id=140) attributeName "addresses" (id=143) >in Thread [main] (Suspended (breakpoint at line 96 in IdentifiableTypeImpl)) EntityTypeImpl<X>(IdentifiableTypeImpl<X>).initializeIdAttributes() line: 96 MetamodelImpl.initialize() line: 440 MetamodelImpl.<init>(DatabaseSession) line: 109 MetamodelImpl.<init>(EntityManagerSetupImpl) line: 128 EntityManagerSetupImpl.getMetamodel() line: 2011 EntityManagerSetupImpl.deploy(ClassLoader, Map) line: 408 EntityManagerFactoryImpl.getServerSession() line: 164 JpaHelper.getServerSession(EntityManagerFactory) line: 161 VirtualModelTest.initializeEMF() line: 59 Created attachment 182325 [details]
ManagedType must handle member attribute from dynamic JPA via ValuesAccessor subclass of AttributeAccessor
>variant (error) testing with forced null member [EL Finest]: 2010-11-03 15:44:22.811--Thread(Thread[Thread-3,6,main])--The java Member is null for the Attribute [declaredCenterStringField] with managedType [MappedSuperclassTypeImpl@25631337:MS_MS_Entity_Center [ javaType: class org.eclipse.persistence.testing.models.jpa.metamodel.MS_MS_Entity_Center descriptor: RelationalDescriptor(org.eclipse.persistence.testing.models.jpa.metamodel.MS_MS_Entity_Center --> [DatabaseTable(__METAMODEL_RESERVED_IN_MEM_ONLY_TABLE_NAME)]), mappings: 2]] and descriptor [RelationalDescriptor(org.eclipse.persistence.testing.models.jpa.metamodel.MS_MS_Entity_Center --> [DatabaseTable(__METAMODEL_RESERVED_IN_MEM_ONLY_TABLE_NAME)])]. [EL Finer]: 2010-11-03 15:46:40.939--DatabaseSessionImpl(5452358)--Thread(Thread[Thread-3,6,main])--Begin MetamodelMetamodelTest [EL Finer]: 2010-11-03 15:46:41.22--DatabaseSessionImpl(5452358)--Thread(Thread[Thread-3,6,main])--Finished MetamodelMetamodelTest >TEST MODEL NAME: (JUnit test): MetamodelMetamodelTest Errors: (failures): 0 Fatal Errors: (errors): 0 Passed: 135 Total Tests: 135 >TEST MODEL NAME: (JUnit test): Criteria Errors: (failures): 0 Fatal Errors: (errors): 0 Passed: 142 Total Tests: 142 >LRG AllCMP3TestRunModel 2169 0 0 1984.462 2010-11-03T19:53:03 xps435 >See SVN Rev# 8472 - thank you Frank S. https://fisheye2.atlassian.com/changelog/eclipselink/?cs=8472 8472 in 2.2 trunk ipLog on patch The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |