Mikaël Peoc'h (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiOWEzYWIyYTU5...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16967?atlOrigin=eyJpIjoiOWEzYW...
) HHH-16967 (
https://hibernate.atlassian.net/browse/HHH-16967?atlOrigin=eyJpIjoiOWEzYW...
) Missing join on inheritance parent table to validate @Where condition (
https://hibernate.atlassian.net/browse/HHH-16967?atlOrigin=eyJpIjoiOWEzYW...
)
Issue Type: Bug Affects Versions: 6.2.7 Assignee: Unassigned Components: query-criteria
Created: 21/Jul/2023 06:52 AM Environment: Detected using Spring Boot 3.1.1, reproduced
using the latest Hibernate Core version available 6.2.7. Labels: core Priority: Major
Reporter: Mikaël Peoc'h (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
Since migrating to Spring Boot 3, I noticed some weird behaviour while using the @Where
annotation acting as a soft delete in conjunction with the joined table inheritance
pattern.
The basic use case is:
* child entity inheriting from a parent entity using the joined table pattern
* The parent entity has a @Where annotation used for detecting a soft delete
* the child entity has 2 OneToMany relations on primary and secondary objects
When trying to get a primary object with a condition on a secondary object going through
the child entity, the @Where condition is applied, but the SQL JOIN condition it produces
isn’t valid
Here is the SQL produced and the error:
SELECT P1_0.ID,
P1_0.CHILD_ID,
P1_0.DATA
FROM PRIMARYOBJECT P1_0
JOIN CHILD C1_0 ON C1_0.ID = P1_0.CHILD_ID
AND (C1_1.DELETED_ON IS NULL)
JOIN SECONDARYOBJECT S1_0 ON C1_0.ID = S1_0.CHILD_ID
WHERE S1_0.DATA = ?
ERROR SqlExceptionHelper:150 - Column "C1_1.DELETED_ON" not found
Here is the PR to reproduce this behaviour.
(
https://hibernate.atlassian.net/browse/HHH-16967#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16967#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#100232- sha1:4329f54 )