Bug 355186 - Unnecessary Table Join in Native Many-to-Many Query generated from JPQL
Summary: Unnecessary Table Join in Native Many-to-Many Query generated from JPQL
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows Vista
: P2 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-19 01:25 EDT by Bernard Missing name CLA
Modified: 2022-06-09 10:04 EDT (History)
1 user (show)

See Also:


Attachments
Testcase (16.91 KB, application/octet-stream)
2011-08-19 01:27 EDT, Bernard Missing name CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bernard Missing name CLA 2011-08-19 01:25:36 EDT
Build Identifier: 2.3.0.v20110604-r9504

The JPQL query

select
    object(emp)
from
    Employee emp
where
    emp.illnesses is empty

creates a a native query that joins the table illness which is not good.

The generated SQL is:

SELECT
    t0.ID
    , t0.NAME
FROM
    EMPLOYEE t0
WHERE (
          (
    SELECT
        COUNT(t1.ID) -- should be count(t2.employee_id)
    FROM
        employee_illness t2
        , ILLNESS t1 -- ############ unnecessary inner join
    WHERE (
            (
        t2.employee_id = t0.ID
             )
        AND (
            t1.ID = t2.illness_id -- ############# unnecessary inner join
            )
           )
          )
       = ?
      )
bind => [0]


Reproducible: Always

Steps to Reproduce:
Please refer to the attached testcase.
Comment 1 Bernard Missing name CLA 2011-08-19 01:27:04 EDT
Created attachment 201765 [details]
Testcase
Comment 2 Tom Ware CLA 2011-09-09 09:02:56 EDT
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines

Community: Please vote for this bug if it is important to you.  Votes are one of the main criteria we use to determine which bugs to fix next.
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:04:35 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink