Bug 1197937 - [GSS](6.4.z)HHH-9637 - Join is reused when 2 explicit joins are used for the same ToOne association
Summary: [GSS](6.4.z)HHH-9637 - Join is reused when 2 explicit joins are used for the ...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Hibernate
Version: 6.3.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: CR1
: EAP 6.4.3
Assignee: Gail Badner
QA Contact: Martin Simka
URL:
Whiteboard:
Depends On:
Blocks: 1231259 1232160
TreeView+ depends on / blocked
 
Reported: 2015-03-03 02:01 UTC by Stephen Fikes
Modified: 2019-07-11 08:43 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-01-17 10:39:27 UTC
Type: Bug


Attachments (Terms of Use)
Maven based testcase adapted from original customer test (9.64 KB, application/zip)
2015-03-03 02:01 UTC, Stephen Fikes
no flags Details

Description Stephen Fikes 2015-03-03 02:01:36 UTC
Created attachment 997294 [details]
Maven based testcase adapted from original customer test

Description of problem:
https://hibernate.atlassian.net/browse/HHH-9637

Version-Release number of selected component (if applicable):
Change introduced by commit dd07167af8e1b4ab11489ce0a3bb7ed92f3ae257 first shipped as part of EAP 6.3.1 (hibernate-core-4.2.14.SP3-redhat-1.jar).

How reproducible:
Consistently

Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Consider the following schema (not the same as attached test which was adapted from what was originally provided by the customer)

@Entity Department {
    private String name;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "department")
    private List<Employee> employees;
}

@Entity Employee {
    private String name;

    @ManyToOne
    @JoinColumn(name = "dept_name")
    private Department department;
}

The following two queries are equivalent in result:

select d.*, e.*
from department d
inner join employee e on e.dept_name = d.name
inner join employee e2 on e2.dept_name = d.name
where e2.name = 'Mike Smith';

select d.*, e.*
from department d
inner join employee e on e.dept_name = d.name
-- inner join employee e2 on e2.dept_name = d.name
where d.name in (
    select d2.name
    from department d2
    inner join employee e2 on e2.dept_name = d2.name
    where e2.name = 'Mike Smith'
);

Both queries will discard any departments which don't include an employee named 'Mike Smith' and the results for both include all employees of any department which *does* include an employee named Mike Smith.

Comment 17 Gail Badner 2015-07-22 01:39:48 UTC
This is fixed upstream with the following commits to 4.2 branch:
* https://github.com/hibernate/hibernate-orm/commit/74f21115ce235f71769de3c363dbb88608ffc48f
* https://github.com/hibernate/hibernate-orm/commit/e740cb6238434432160b573bc3f765f48d8012ec (fixes test case only)

Comment 19 Jan Martiska 2015-07-30 12:41:34 UTC
Verified in EAP 6.4.3.CR1 / Hibernate 4.2.20.Final-redhat-1

Comment 21 Petr Penicka 2017-01-17 10:39:27 UTC
Retroactively bulk-closing issues from released EAP 6.4 cummulative patches.

Comment 22 Petr Penicka 2017-01-17 10:40:12 UTC
Retroactively bulk-closing issues from released EAP 6.4 cumulative patches.


Note You need to log in before you can comment on or make changes to this bug.