Mikaël Peoc'h (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMjg2NjQ3ZTJm...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16967?atlOrigin=eyJpIjoiMjg2Nj...
) HHH-16967 (
https://hibernate.atlassian.net/browse/HHH-16967?atlOrigin=eyJpIjoiMjg2Nj...
) Missing join on inheritance parent table to validate @Where condition (
https://hibernate.atlassian.net/browse/HHH-16967?atlOrigin=eyJpIjoiMjg2Nj...
)
Change By: 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:
{quote}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 = ?{quote}
{{ERROR SqlExceptionHelper:150 - Column "C1_1.DELETED_ON" not found}}
Here is the PR to reproduce this behaviour :
[
https://github.com/hibernate/hibernate-test-case-templates/pull/ 297 300
|https://github.com/hibernate/hibernate-test-case-templates/pull/ 297 300 |smart-link]
(
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#100233- sha1:f5b6255 )