Community
Participate
Working Groups
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.
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.
Created attachment 184823 [details] Proposed fix
Fixed in trunk (2.2) revision: 8681
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink