This issue can't be edited

Because it belongs to an archived project. Jira admins can restore projects from the archive.

Many-to-Many: Unnecessary Table Join in generated SQL

Description

A simple JPQL query produces an unnecessary table join.

Please refer to the attached testcase (NetBeans project).

JPQL:

select
object(emp)
from
Employee emp
, in(emp.projects) proj
where
proj = roject

The generated native SQL is:

select
employee0_.id as id2_,
employee0_.name as name2_
from
Employee employee0_
inner join
Employee_Project projects1_
on employee0_.id=projects1_.Employee_id
inner join
Project project2_
on projects1_.projects_id=project2_.id
where
project2_.id=?

The generated SQL should have only one join, in other words the project table should not be included.

Please refer to the attached testcase if this is useful - you need to set up the required libraries.

Environment

java version "1.6.0_25" Java(TM) SE Runtime Environment (build 1.6.0_25-b06) Java HotSpot(TM) Client VM (build 20.0-b11, mixed mode, sharing)

Attachments

1

Activity

Show:

Details

Assignee

Reporter

Bug Testcase Reminder (view)

Bug reports should generally be accompanied by a test case!

Bug Testcase Reminder (edit)

Bug reports should generally be accompanied by a test case!

Participants

b

Priority

Created August 22, 2011 at 2:29 AM
Updated August 22, 2011 at 2:29 AM