This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 303268 - JP QL expression order can result in QueryException
Summary: JP QL expression order can result in QueryException
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-18 22:46 EST by Shaun Smith CLA
Modified: 2022-06-09 10:33 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Shaun Smith CLA 2010-02-18 22:46:20 EST
In a model with CollectedSeries having a ManyToOne to Publisher, the following query results in the exception below:

  select distinct(p) from Publisher p, CollectedSeries s 
    where s.publisher = p
    order by p.name

Reversing the order of the arguments to the "=" does not result in an exception and everything works fine:

  select distinct(p) from Publisher p, CollectedSeries s 
    where p = s.publisher
    order by p.name

This problem is related to restrictions on Expression ordering when using multiple ExpressionBuilders.  This was a known restriction when using EclipseLink Expressions however JP QL queries should not be affected by the expression order rules of the underlying Expression framework.

Local Exception Stack: 
Exception [EclipseLink-6089] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.QueryException
Exception Description: The expression has not been initialized correctly.  Only a single ExpressionBuilder should be used for a query. 
For parallel expressions, the query class must be provided to the ExpressionBuilder constructor, and the query's ExpressionBuilder must 
always be on the left side of the expression. 
Expression: [
Base org.eclipse.persistence.gcd.model.CollectedSeries]
	at org.eclipse.persistence.exceptions.QueryException.noExpressionBuilderFound(QueryException.java:855)
	at org.eclipse.persistence.expressions.ExpressionBuilder.getDescriptor(ExpressionBuilder.java:195)
	at org.eclipse.persistence.internal.expressions.DataExpression.getMapping(DataExpression.java:232)
	at org.eclipse.persistence.internal.expressions.QueryKeyExpression.getMapping(QueryKeyExpression.java:362)
	at org.eclipse.persistence.internal.expressions.RelationExpression.isObjectComparison(RelationExpression.java:360)
	at org.eclipse.persistence.internal.expressions.RelationExpression.normalize(RelationExpression.java:383)
	at org.eclipse.persistence.internal.expressions.SQLSelectStatement.normalize(SQLSelectStatement.java:1306)
	at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.buildNormalSelectStatement(ExpressionQueryMechanism.java:482)
	at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.prepareSelectAllRows(ExpressionQueryMechanism.java:1553)
	at org.eclipse.persistence.queries.ReadAllQuery.prepareSelectAllRows(ReadAllQuery.java:793)
	at org.eclipse.persistence.queries.ReadAllQuery.prepare(ReadAllQuery.java:734)
	at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:464)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.checkPrepare(ObjectLevelReadQuery.java:732)
	at org.eclipse.persistence.queries.DatabaseQuery.prepareCall(DatabaseQuery.java:1577)
	at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:240)
	at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:173)
	at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:125)
	at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:109)
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1326)
	at comics.ui.GCDComicsV.getCandidatePublishers(GCDComicsV.java:424)
	at comics.ui.GCDComicsV.createContents(GCDComicsV.java:112)
	at org.eclipse.jface.window.Window.create(Window.java:431)
	at org.eclipse.jface.window.Window.open(Window.java:790)
	at comics.ui.GCDComicsV.open(GCDComicsV.java:314)
	at comics.ui.GCDComicsV.main(GCDComicsV.java:303)
Comment 1 James Sutherland CLA 2011-11-23 13:12:06 EST
This seems to work now.
Test added, and passes.
A fix for one of the other issues most likely fixed this.
Comment 2 Eclipse Webmaster CLA 2022-06-09 10:14:14 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:33:56 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink