users@glassfish.java.net

Syntax error parsing the query with JOIN FETCH

From: <glassfish_at_javadesktop.org>
Date: Thu, 03 Apr 2008 00:16:30 PST

Hi,

We have the following relationship:
*********************************
* CallDistributionGroup *
*********************************
* id *
* supportAgents *
* *******************************
 
OneToMany relationship ( One cdg --< Many agents).
 
*********************************
* SupportAgents *
*********************************
* address *
* CallDistributionGroup *
* *
*********************************

Since we wanted also to load the SupportAgents ( avoid lazy loading) there were two options:

1. navigate relationship in persistence context.
2. use a JOIN FETCH in query.

So We use alt. 2 with the following query (EJB QL ):

"SELECT cdg FROM CallDistributionGroup cdg LEFT JOIN FETCH cdg.supportAgents li WHERE li.address = :address"

We get a parse error on this:

java.lang.AssertionError:
Exception Description: Syntax error parsing the query [CallDistributionGroup.findCdgByAgentAddress: SELECT cdg FROM CallDistributionGroup cdg LEFT JOIN FETCH cdg.supportAgents li WHERE li.address = :agentSipAddress], line 1, column 77: unexpected token [li].
Internal Exception: line 1:77: unexpected token: li
        at org.junit.Assert.fail(Assert.java:74)
        at com.ericsson.wong.domain.DomainStuffTest.setUp(DomainStuffTest.java:80)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

Is there something missing in in my query?

We use toplink v2 b41 of toplink essentials.

cheers,

//mike
[Message sent by forum member 'eraonel' (eraonel)]

http://forums.java.net/jive/thread.jspa?messageID=267478