Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 332080 - DB Fields for relationship mappings are not translated in AggregateObjectMapping
Summary: DB Fields for relationship mappings are not translated in AggregateObjectMapping
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-07 15:08 EST by David Minsky CLA
Modified: 2022-06-09 10:29 EDT (History)
0 users

See Also:


Attachments
Testcase demonstrating problems with relationships from aggregates (91.98 KB, patch)
2010-12-08 17:30 EST, David Minsky CLA
no flags Details | Diff
Proposed fix (5.43 KB, patch)
2010-12-08 17:31 EST, David Minsky CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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