Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Outer joined one-to-many question

How about:

SELECT p.id
  FROM Parent p
  LEFT OUTER JOIN p.children children
 WHERE
   children IS EMPTY OR
EXISTS(SELECT child FROM Child child WHERE (child IN (p.children) AND child.x = 'y'))



On 8/19/2013 2:15 PM, Laird Nelson wrote:
On Mon, Aug 19, 2013 at 2:04 PM, Andrei Ilitchev
<andrei.ilitchev@xxxxxxxxxx <mailto:andrei.ilitchev@xxxxxxxxxx>> wrote:

    Should be something like:

    "SELECT e FROM Employee e LEFT OUTER JOIN e.projects projects WHERE
    (e.projects IS EMPTY OR EXISTS(SELECT p FROM Project p WHERE (p
    IN(e.projects) AND p.name <http://p.name> LIKE 'A%')))"


Now I'm even more confused.  :-)

I get the gist of what you're saying.

Now I'm getting NullPointerExceptions from inside EclipseLink.

My old query said this:

SELECT p.id <http://p.id>
   FROM Parent p
   LEFT OUTER JOIN p.children child
  WHERE child IS NULL OR child.x = 'y' ....

My new query says this:

SELECT p.id <http://p.id>
   FROM Parent p
   LEFT OUTER JOIN p.children child
  WHERE child IS EMPTY OR child.x = 'y' ....

Doing this causes this:

Query failed to prepare, unexpected error occurred:
[java.lang.NullPointerException].
Internal Exception: java.lang.NullPointerException
Query: JPAQuery(name="Parent.foobar" )
at
org.eclipse.persistence.exceptions.QueryException.prepareFailed(QueryException.java:1555)
at
org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:625)
at
org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:575)
at
org.eclipse.persistence.internal.sessions.AbstractSession.processJPAQueries(AbstractSession.java:2161)
at
org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:442)
at
org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:676)
at
org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:634)
at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:208)
at
org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:488)
... 39 more
Caused by: java.lang.NullPointerException
at
org.eclipse.persistence.internal.jpa.parsing.EmptyCollectionComparisonNode.generateExpression(EmptyCollectionComparisonNode.java:57)
Is there something about the join alias ("child") that is causing this?
Or...?

Best,
Laird
--
http://about.me/lairdnelson


_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users



Back to the top