[BAEL-2538] Updated to return int with @Modifying queries

This commit is contained in:
dupirefr 2019-02-17 17:07:18 +01:00
parent dabbf763b6
commit 099a8c9ae7
2 changed files with 4 additions and 3 deletions

View File

@ -79,8 +79,8 @@ public interface UserRepository extends JpaRepository<User, Integer> , UserRepos
void deactivateUsersNotLoggedInSince(@Param("date") LocalDate date);
@Modifying(clearAutomatically = true, flushAutomatically = true)
@Query("delete User u where u.active = false")
void deleteDeactivatedUsers();
@Query("delete from User u where u.active = false")
int deleteDeactivatedUsers();
@Modifying(clearAutomatically = true, flushAutomatically = true)
@Query(value = "alter table USERS.USERS add column deleted int(1) not null default 0", nativeQuery = true)

View File

@ -501,11 +501,12 @@ public class UserRepositoryIntegrationTest {
userRepository.save(usr01);
userRepository.save(usr02);
userRepository.deleteDeactivatedUsers();
int deletedUsersCount = userRepository.deleteDeactivatedUsers();
List<User> users = userRepository.findAll();
assertEquals(1, users.size());
assertEquals(usr01, users.get(0));
assertEquals(1, deletedUsersCount);
}
@Test