persistence@glassfish.java.net

Re: Workaround for Showstopper needed

From: James Sutherland <jamesssss_at_yahoo.com>
Date: Tue, 17 Jun 2008 07:23:10 -0700 (PDT)

You need to use an outerjoin for this. Relationships are accessed through
inner joins by default.

i.e. in your FROM clause left outer join a.fb



Markus KARG-3 wrote:
>
> I want to ask if somebody knows a workaround for this bug:
>
>
>
> https://glassfish.dev.java.net/issues/show_bug.cgi?id=5171
>
>
>
> I have written the following query:
>
>
>
> SELECT DISTINCT a FROM A a WHERE (1=1) OR (a.fb.cb=?1)
>
>
>
> Obviously the WHERE clause is "TRUE OR ...", so it should always return
> ALL values.
>
>
>
> Actually, if a.fb contains NULL, then that row is mssing in the result
> set.
>
>
>
> For me, TRUE OR NullPointerException should be still TRUE, since this is
> the
>
> core idea of the OR statement. But it seems as if TopLink handles it
>
> differently: "TRUE OR anything is TRUE until 'anything' is a
> NullPointerException".
>
>
>
> (Actually the 1=1 is only a simulation to provoke and demonstrate the
> buggy
>
> behaviour. Certainly the real query we are running is much more complex
> and does
>
> not include a static 1=1 comparison. We just wrote 1=1 to demonstrate that
> the
>
> OR is behaving very strange in case of NullPointerException).
>
>
>
> This is very problematic, since we need to run queries of the form "If
> there is
>
> an object referenced, check some fields of that object. If no object is
> linked,
>
> just take the row as it is."
>
>
>
> Since we do not see any workaround, this is an absolute showblocker for
> us.
>
>
>
> Thanks a lot! :-)
>
> Markus
>


-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/Workaround-for-Showstopper-needed-tp17903743p17908842.html
Sent from the java.net - glassfish persistence mailing list archive at Nabble.com.