Skip to content
Advertisement

Spring Data JPA Native SQL Query DELETE SQL Query

I use @Modifying annotation together with @Query annotation to perform SQL DELETE query and delete the record from a database table.

Error:

Exception in xxx.xxx.xx with cause = ‘javax.persistence.TransactionRequiredException: Executing an update/delete query’ and exception = ‘Executing an update/delete query; nested exception is javax.persistence.TransactionRequiredException: Executing an update/delete query’

Advertisement

Answer

Annotate the service method with @Transactional. Your query is wrong. Try this:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement