Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EJBQL translaltion problem
EJBQL translaltion problem [message #383018] Wed, 12 November 2008 11:10 Go to next message
Milos is currently offline MilosFriend
Messages: 12
Registered: July 2009
Junior Member
Hi, all!

I ran into pretty interesting problem using Toplink previosly, so it turned
out that Eclipselink does the same thing.

I have EJBQL query like this (taken from Java code):

"SELECT distinct i FROM NumberTestA i WHERE ( " +

"( ( ?1 = true ) OR i.acol <> ?2 ) AND " +

" ( ( ?3 is null ) OR i.str = ?4 ) " +
") ORDER BY i.acol";





parameters 1 and 3 are set as boolean, true in case that parameters 2 and 4
are null (checked before that in java code).



Anyway, this kind of query kind of confuses our persistence provider. It
gets translated into this:



SELECT DISTINCT t1.ID, t1.DTYPE, t1.NUM, t1.STR, t1.ACOL,

t0.ACOL

FROM NUMBER_TEST t0, NUMBER_TEST t1

WHERE (((((? = ?) OR (t0.ACOL <> ?))

AND ((? IS NULL) OR (t0.STR = ?)))

AND (t0.DTYPE = ?))

AND (t1.DTYPE = ?))

ORDER BY t0.ACOL ASC
bind => [false, true, X, true, z, NumberTestA, NumberTestA]



So i get cartesian on my table, without any join condition. In case of table
with 2000 rows... You get the picture.



It is easy for me to make workaround on this, I simply split query string
into separate conditions and put them, as well as setting parameters with
bunch of if conditions, checking whether passed param is null, bu this looks
like an issue, something that confuses both Toplink and Eclipselink, so I
thought I should point to this.



Best,

Milos
Re: EJBQL translaltion problem [message #383028 is a reply to message #383018] Mon, 17 November 2008 14:54 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

This seems to be a bug, please log this bug in Bugzilla.

I'm not certain why EclipseLink would generate the extra table in the from
clause, it seems related to the parameters being on the left, switching to
"true = ?1" may resolve the issue.

Please also include your changes that make it work in the bug.

---
James
http://www.nabble.com/EclipseLink---Users-f26658.html


James : Wiki : Book : Blog : Twitter
Previous Topic:EclipseLink Test suite and Ingres
Next Topic:I must be missing something!
Goto Forum:
  


Current Time: Sun Nov 23 22:31:37 GMT 2014

Powered by FUDForum. Page generated in 0.01571 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software