I am using spring-data-jpa to perform delete operation.
Currently, I have a query like:
@Modifying
@Transactional
@Query("Delete from student s where(:studentName is null Or s.studentName =:studentName) and s.studentId IN(:studentIds)")
int deleteByStudentIdAndRollNo(@Param("studentName") String studentName, @Param("studentIds") List<Integer> studentIds)
The above query is working fine and is returning a count of successfully deleted rows from the table.
But the problem is, now I have to return deleted List<Students> instead of the number of deleted records.
I am aware of the fact that @Query will always return the count of successfully deleted records.
I tried to use deleteBy like below:
List<Student> deleteByStudentIdStudentNameIsNullOrStudentNameIsAndStudentIdIN
, But that's not working.
Is there any way to get list of deleted students?