Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 347563

Summary: transient field/property in embeddable entity
Product: z_Archived Reporter: Martin Priekopa <priekopa>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipselink.foundation-inbox, tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard: submitted_patch
Attachments:
Description Flags
Patch none

Description Martin Priekopa CLA 2011-05-28 18:52:29 EDT
Build Identifier: EclipseLink, version: Eclipse Persistence Services - 2.2.0.v20110202-r8913

- it is not possible to have transient field in the embeddable entity (C) that is associated from other embeddable entity (B) participating in embeddable element collection
- A ->* B -> C@transientField; A - plain persistent entity; B, C - embeddable classes
- my quickfix: ElementCollectionAccessor.java

@@ -754,10 +795,13 @@
             if (! mappingAccessor.isProcessed()) {
                 mappingAccessor.process();
             }
-            
+
             // Now you can safely grab the mapping off the accessor.
             DatabaseMapping mapping = mappingAccessor.getMapping();
-            
+            if (mapping == null) {
+        	continue;
+            }
+
             // Figure out what our override name is to ensure we find and 
             // apply the correct override metadata.
             String overrideName = (dotNotationName.equals("")) ? mapping.getAttributeName() : dotNotationName + "." + mapping.getAttributeName();


Reproducible: Always

Steps to Reproduce:
1. create mapping such as: A ->* B -> C@transientField; A - plain persistent entity; B, C - embeddable classes
2. configure persistence unit & runtest
3. exception is thrown
Caused by: java.lang.NullPointerException
	at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ElementCollectionAccessor.processMappingsFromEmbeddable(ElementCollectionAccessor.java:804)
Comment 1 Eric Gwin CLA 2011-05-30 06:58:01 EDT
This appears to be a foundation bug. Not related to the build system. Reassigning.
Comment 2 Tom Ware CLA 2011-06-02 10:41:10 EDT
Investigating patch
Comment 3 Guy Pelletier CLA 2011-06-02 15:57:12 EDT
I've reproduced your problem, however only when the transient is mapped through
XML. Safe to assume your transient is mapped in XML?

Mapping it with @Transient (and removing the XML mapping) should get you past
the NPE for the time being.
Comment 4 Guy Pelletier CLA 2011-06-03 14:31:04 EDT
Created attachment 197323 [details]
Patch
Comment 5 Martin Priekopa CLA 2011-06-06 06:21:13 EDT
yes, sry about forgetting to mention that i used XML to specify OR mappings. too much mojitos ... ;).

(In reply to comment #3)
> I've reproduced your problem, however only when the transient is mapped through
> XML. Safe to assume your transient is mapped in XML?
> 
> Mapping it with @Transient (and removing the XML mapping) should get you past
> the NPE for the time being.
Comment 6 Guy Pelletier CLA 2011-06-06 14:28:27 EDT
Changes submitted to the main trunk. Once the 2.3.1 stream opens this fix will be submitted there as well.

Verified by: Tom Ware

Tests: Metadata processing error. Model change made to expose error. With fix in place the error goes away and all tests pass (FullRegressionTestSuite)
Comment 7 Guy Pelletier CLA 2011-06-28 10:45:37 EDT
Changes have been submitted to the 2.3.1 stream
Comment 8 Eclipse Webmaster CLA 2022-06-09 10:32:13 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink