persistence@glassfish.java.net

EJBQL FETCH JOIN query with many-to-many relationship

From: Michael Bouschen <Michael.Bouschen_at_Sun.COM>
Date: Tue, 15 Nov 2005 18:53:12 +0100

Hi Tom,

Shelly pointed me to a problem with an EJBQL query having a FETCH JOIN
clause for a many-to-many relationship field. Classes Customer and Alias
  have a many-to-many relationship: Customer.aliases<->Alias.customers.
The query
   SELECT c FROM Customer c JOIN FETCH c.aliases
fails with the exception:
   The join expression
     Query Key aliases
       Base oracle.toplink.examples.Customer is not valid, or for a
mapping type that does not support joining.

Using the relationship from the other side gives the same exception
complaining about Query Key customers:
   SELECT a FROM Alias a JOIN FETCH a.customers

I can successfully execute a query fetching the collection relationship
field from a one-to-many relationship:
   SELECT c FROM Customer c JOIN FETCH c.orders

Do you have an idea?

Regards Michael