-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed as not planned
Closed as not planned
Copy link
Labels
for: external-projectFor an external project and not something we can fixFor an external project and not something we can fix
Description
In springboot 3.3.9 (using spring-data-jpa 3.3.9 and hibernate 6.5.3), a with clause supports delete operations - e.g.
@Transactional
@Modifying
@Query(nativeQuery = true,
value = """
with to_delete as (select id from person where birthday < :birthday)
delete from person where id in (select id from to_delete)
""")
int deleteByBirthday(@Param("birthday") Date birthday);
In springboot 3.4.3 (using spring-data-jpa 3.4.3 and hibernate 6.6.8), this same query generates the following error
Syntax error in SQL statement "with to_delete as (select id from person where birthday < ?)\000a [*]delete from person where id in (select id from to_delete)\000a"; expected ",, (, SELECT, TABLE, VALUES"; SQL statement:
with to_delete as (select id from person where birthday < ?)
delete from person where id in (select id from to_delete)
The attached sample project shows the issue - just change the springboot version in the pom
In my real world scenario I use this form of query in a loop where I also add an order by and limit clause so I do not overload my DB trying to delete 1000s of rows in a single transaction.
The springboot team also overrode my sample to use Hibernate 6.5.3, and it still failed, so the error appears to be in spring-data-jpa - ref spring-projects/spring-boot#44744
Metadata
Metadata
Assignees
Labels
for: external-projectFor an external project and not something we can fixFor an external project and not something we can fix