Stefan Seidel (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=6070150...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiN2U2MzA2NGY2...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16434?atlOrigin=eyJpIjoiN2U2Mz...
) HHH-16434 (
https://hibernate.atlassian.net/browse/HHH-16434?atlOrigin=eyJpIjoiN2U2Mz...
) @Where condition duplicated and join is not left join when using EntityGraph (
https://hibernate.atlassian.net/browse/HHH-16434?atlOrigin=eyJpIjoiN2U2Mz...
)
Issue Type: Bug Affects Versions: 6.2.0.CR4 Assignee: Unassigned Created: 04/Apr/2023
06:27 AM Priority: Major Reporter: Stefan Seidel (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=6070150...
)
Test Case:
https://github.com/s-seidel/hibernate-test-case-templates/tree/entity-gra...
Test:
https://github.com/s-seidel/hibernate-test-case-templates/blob/5a84472593...
The SQL query that is generated is:
select
e1_0. "id" ,
c1_0. "employeeid" ,
c1_0. "skillid" ,
s1_0. "id" ,
c1_0. " end " ,
c1_0. " start "
from
"employee" e1_0
left join
"skillassignment" c1_0
on e1_0. "id" =c1_0. "employeeid"
and (
c1_0. " start " <= cast ( current_timestamp as date )
and (
c1_0. " end " >= cast ( current_timestamp as date )
or c1_0. " end " is null
)
)
and (
c1_0. " start " <= cast ( current_timestamp as date )
and (
c1_0. " end " >= cast ( current_timestamp as date )
or c1_0. " end " is null
)
)
join
"skill" s1_0
on s1_0. "id" =c1_0. "skillid"
But the expected (and in Hibernate 5, actual) Query should be:
select
e1_0. "id" ,
c1_0. "employeeid" ,
c1_0. "skillid" ,
s1_0. "id" ,
c1_0. " end " ,
c1_0. " start "
from
"employee" e1_0
left join
"skillassignment" c1_0
on e1_0. "id" =c1_0. "employeeid"
and (
c1_0. " start " <= cast ( current_timestamp as date )
and (
c1_0. " end " >= cast ( current_timestamp as date )
or c1_0. " end " is null
)
)
LEFT join
"skill" s1_0
on s1_0. "id" =c1_0. "skillid"
So the where clause is duplicated and the join to skill is not a LEFT join anymore,
leading to too few results - the idea is that skillassignment is optional, therefore skill
must also be optional.
(
https://hibernate.atlassian.net/browse/HHH-16434#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16434#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100221- sha1:89dc9bf )