Quantcast

WHERE a.bref IS NULL or a.bref.x. = v as an OUTER JOIN

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

WHERE a.bref IS NULL or a.bref.x. = v as an OUTER JOIN

Markus KARG-3

How to make a WHERE clause produce an LEFT OUTER JOIN?

 

Scenario:

 

A.bref refers to B and can be NULL.

B.x is a non-NULL field.

 

We like to write the following:

 

SELECT a.id FROM A a WHERE a.bref IS NULL or a.bref.x = v

 

The problem is that this produces an INNER JOIN between A and B.

 

We could workaround that by explicitly writing FROM A a LEFT OUTER JOIN a.bref b, but actually we wonder whether there is a different way to tell EclipseLink that the “dot” between bref.x does NOT automatically imply an INNER joint. For example, we could imagine that some annotation at a.bref might solve this?

 

Thanks!

-Markus

 

 

 


_______________________________________________
eclipselink-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: WHERE a.bref IS NULL or a.bref.x. = v as an OUTER JOIN

Mauro Molinari
Il 18/04/2017 17:09, Markus Karg ha scritto:
SELECT a.id FROM A a WHERE a.bref IS NULL or a.bref.x = v

 

The problem is that this produces an INNER JOIN between A and B.

 

We could workaround that by explicitly writing FROM A a LEFT OUTER JOIN a.bref b, but actually we wonder whether there is a different way to tell EclipseLink that the “dot” between bref.x does NOT automatically imply an INNER joint. For example, we could imagine that some annotation at a.bref might solve this?


This is by JPA specification and AFAIK there's no way to change this, unless you use an explicit LEFT OUTER JOIN.

Mauro

_______________________________________________
eclipselink-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
Loading...