Burner (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=6423fd4...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMTJiYjk5MDQx...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16478?atlOrigin=eyJpIjoiMTJiYj...
) HHH-16478 (
https://hibernate.atlassian.net/browse/HHH-16478?atlOrigin=eyJpIjoiMTJiYj...
) SubQuery don't use table alias in Hibernate 6.1.7 (
https://hibernate.atlassian.net/browse/HHH-16478?atlOrigin=eyJpIjoiMTJiYj...
)
Change By: Burner (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=6423fd4...
)
I want to implement a soft delete for my entities. So I create this annoations:
{noformat}@SQLDelete(sql = "UPDATE ExternalReference SET deleted=true,
deletedAt=now() WHERE id=?")
@Where(clause = "deleted = false")
public class ExternalReference {
...
}{noformat}
Repository:
{noformat}public interface ExternalReferenceRepo extends
JpaRepository<ExternalReference, Long> {
@Modifying
@Query("DELETE FROM #{#entityName} e WHERE e. id externalSystem = : iId
iExternalSystem AND e.externalClass = :iExternalClass AND e.externalId = :iExternalId
")
void delete(@Param(" iId iExternalSystem ") Long id String externalSystem,
@Param("iExternalClass" ) String externalClass,
@Param("iExternalId") String externalId) ;
}{noformat}
When I use the method delete. Hibernate create this SQL:
{code:sql}DELETE
FROM external_reference_our_object
WHERE external_reference_our_object.external_reference_id in
(SELECT e1_0.id
FROM external_reference e1_0
WHERE e1_0.external_system=?
AND e1_0.external_class=?
AND e1_0.external_id=?
AND (external_reference.deleted = 0))];{code}
And I get this Error Message:
{panel:bgColor=#deebff}
SQL Error: 1054, SQLState: 42S22
(conn=43) Unknown column 'external_reference.deleted' in 'where clause'
{panel}
Because {{external_reference.deleted}} should be {{e1_0.deleted}}
(
https://hibernate.atlassian.net/browse/HHH-16478#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16478#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:d40a829 )