Search code examples
javahibernatespring-bootjpajpql

jpql delete query is active since long time


jpql delete query is active for last 4 hours. When I tried to execute the same query directly on the database console it took around 30seconds to execute.The total data to delete is maximum 100000. I have index on id. I am unable to understand. Any suggestions would be appreciated. Thanks

@Modifying
    @Query("DELETE FROM IoEntity WHERE Id = :id")
    void deleteAllById(@Param("id") UUID id);

Solution

  • Whenever you run a DML in your DB using SQL clients like Toad, SQL Developer etc, make sure you commit it unless auto commit is turned on in the client.

    If you are doing the delete via JPA, commit will be taken care by Spring when you define @Transactional in your service method.