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

Bug 332080

Summary: DB Fields for relationship mappings are not translated in AggregateObjectMapping
Product: z_Archived Reporter: David Minsky <david.minsky>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Testcase demonstrating problems with relationships from aggregates
none
Proposed fix none

Description David Minsky CLA 2010-12-07 15:08:19 EST
When defining a relationship mapping on an Aggregate descriptor, the fields are not translated correctly. This leads to incorrect SQL generation when querying the mapped relationship.

Example stack trace:

Caused by: Exception [EclipseLink-6094] (Eclipse Persistence Services - @VERSION@.@QUALIFIER@): org.eclipse.persistence.exceptions.QueryException
Exception Description: The parameter name [stepChild->PARENT_ID_IN_REFERENCE_STEPCHILD_PARENT] in the query's selection criteria does not match any parameter name defined in the query.
Query: ReadObjectQuery(name="stepChild" referenceClass=StepChild sql="SELECT ID, PARENT_ID FROM AGG_STEPCHILD WHERE (PARENT_ID = ?)")
	at org.eclipse.persistence.exceptions.QueryException.parameterNameMismatch(QueryException.java:1050)
	at org.eclipse.persistence.internal.expressions.ParameterExpression.getValue(ParameterExpression.java:246)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseCall.translate(DatabaseCall.java:951)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:206)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:193)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectOneRow(DatasourceCallQueryMechanism.java:667)
	at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectOneRowFromTable(ExpressionQueryMechanism.java:2603)
	at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectOneRow(ExpressionQueryMechanism.java:2574)
	at org.eclipse.persistence.queries.ReadObjectQuery.executeObjectLevelReadQuery(ReadObjectQuery.java:444)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1080)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:808)


EL is unable to make the associations defined in the AggregateObjectMapping, and so uses the field names defined within the aggregate descriptor for the mappings. When EL can't make/find the association, it will use the name as the database fieldname.

This is relevant to foreign reference mappings, which need to be translated during the field translation for an aggregate mapping.
Comment 1 David Minsky CLA 2010-12-08 17:30:43 EST
Created attachment 184822 [details]
Testcase demonstrating problems with relationships from aggregates

Testcase includes an updated version of CommitOrderTest (FeatureTestModel) to add in the new model classes added to AggregateTestModel, as well as tweak the comments and readability of that testcase.
Comment 2 David Minsky CLA 2010-12-08 17:31:13 EST
Created attachment 184823 [details]
Proposed fix
Comment 3 David Minsky CLA 2010-12-09 17:09:08 EST
Fixed in trunk (2.2) revision: 8681
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:29:23 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink