|
Quick Lists
|
|
Bug ID:
|
4517005
|
|
Votes
|
0
|
|
Synopsis
|
incorrect EJB QL results for some compound WHERE clause expressions
|
|
Category
|
j2ee:ejbql
|
|
Reported Against
|
1.3fcs
|
|
Release Fixed
|
1.3.1
|
|
State
|
11-Closed,
Unverified,
bug
|
|
Priority:
|
2-High
|
|
Related Bugs
|
|
|
Submit Date
|
19-OCT-2001
|
|
Description
|
EJB QL queries with WHERE clauses that contain at least one OR or AND
and have a simple conditional expression with at least one navigation
expression that requires a join can produce invalid results under
certain conditions.
e.g. SELECT OBJECT(o) FROM Order AS o WHERE
((o.quantity > 1) OR (o.shipping_address.city LIKE '%p%'))
The generated SQL is :
SQL : SELECT "o"."orderId"
"OrderEJB_shipping_address_AddressEJB_Table" "@tmp2"
WHERE (("o"."quantity" > 1 ) OR ("@tmp1"."city" LIKE '%p%' )) AND
(("o"."orderId" = "@tmp2"."_OrderEJB_orderId" AND
"@tmp2"."_AddressEJB_addressId" = "@tmp1"."addressId"))
In this case, the generated sql does not correctly preserve the OR
condition. Since the join tables are in the top-level FROM clause,
if those tables are empty it will wipe out the result set, even if
the o.quantity > 1 is true for some rows.
|
|
Work Around
|
N/A
|
|
Evaluation
|
in cases where evaluating a simple conditional expression requires additional
join tables, generate a sub-query instead of putting sql at top-level.
This will isolate the evaluation and produce the correct results.
E.g. :
SELECT OBJECT(o) FROM Order AS o WHERE
((o.quantity > 1) OR (o.shipping_address.city LIKE '%p%'))
BEFORE :
The generated SQL is :
SELECT "o"."orderId"
"OrderEJB_shipping_address_AddressEJB_Table" "@tmp2"
WHERE (("o"."quantity" > 1 ) OR ("@tmp1"."city" LIKE '%p%' )) AND
(("o"."orderId" = "@tmp2"."_OrderEJB_orderId" AND
"@tmp2"."_AddressEJB_addressId" = "@tmp1"."addressId"))
AFTER :
SELECT "o"."orderId"
FROM "OrderBeanTable" "o"
WHERE (("o"."quantity" > 1 ) OR
EXISTS (SELECT * FROM "AddressBeanTable" "@tmp1" ,
"OrderEJB_shipping_address_AddressEJB_Table" "@tmp2" WHERE
("@tmp1"."city" LIKE '%p%' ) AND (("o"."orderId" =
"@tmp2"."_OrderEJB_orderId" AND "@tmp2"."_AddressEJB_addressId" =
"@tmp1"."addressId"))) )
|
|
Comments
|
Submitted On 05-JUN-2002
Set-i
This bug appears to have been closed erroneously.
Please see http://forum.java.sun.com/
thread.jsp?forum=13&thread=263005
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |