Issue Details (XML | Word | Printable)

Key: GLASSFISH-186
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Critical Critical
Assignee: mb124283
Reporter: smcgowan
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
glassfish

EJB QL: Unused "Join" Variable results in incorrect results

Created: 24/Jan/06 10:52 AM   Updated: 30/Nov/10 05:19 PM   Resolved: 08/Mar/06 10:38 AM
Component/s: entity-persistence
Affects Version/s: 9.0pe
Fix Version/s: 9.0pe_dev

Time Tracking:
Not Specified

Environment:

Operating System: All
Platform: Sun


Issuezilla Id: 186
Tags:
Participants: mb124283, pkrogh and smcgowan


 Description  « Hide

Incorrect results are received from the following query:

Select c from Customer c, IN(c.orders) o

The result returns all customers and not the customers with orders.



mb124283 added a comment - 25/Jan/06 08:05 AM

The generated SQL misses a join clause for the orders relationship in Customer,
so it returns all Customers, even the ones not having any Orders.

SQL: SELECT ID, NAME, VERSION, CITY, COUNTRY_CODE, COUNTRY_NAME, COUNTRY_ID
FROM CUSTOMER_TABLE


pkrogh added a comment - 07/Mar/06 12:07 PM

Raising priority as this is a CTS issue. Reassigning to MB.


mb124283 added a comment - 08/Mar/06 05:53 AM

Started looking into this.

Michael


mb124283 added a comment - 08/Mar/06 10:38 AM

I changed the EJBQL compiler to call reportQuery.addNonFetchJoinedAttribute for
all variables that are defined in the FROM clause, but not used in the WHERE or
SELECT clause. This makes sure the generated SQL includes a foreign key join
clause for c.orders, such that only customers with orders are returned.