diff --git a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/database/repository/UniqueValueRepository.java b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/database/repository/UniqueValueRepository.java index 8a41cb68f..0b37ae881 100644 --- a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/database/repository/UniqueValueRepository.java +++ b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/database/repository/UniqueValueRepository.java @@ -18,19 +18,23 @@ package io.getlime.security.powerauth.app.server.database.repository; import io.getlime.security.powerauth.app.server.database.model.entity.UniqueValueEntity; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; import java.util.Date; /** - * Repository for accessing stored tokens for token-based authentication. + * Repository for accessing unique values related to cryptography. * - * @author Petr Dvorak, petr@wultra.com + * @author Roman Strobl, roman.strobl@wultra.com */ @Repository public interface UniqueValueRepository extends CrudRepository { - int deleteAllByTimestampExpiresBefore(Date timestampExpires); + @Modifying + @Query("DELETE FROM UniqueValueEntity u WHERE u.timestampExpires < :timestampExpires") + int deleteExpiredValues(Date timestampExpires); } diff --git a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/replay/ReplayPersistenceService.java b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/replay/ReplayPersistenceService.java index e3951b9ca..db8f8886d 100644 --- a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/replay/ReplayPersistenceService.java +++ b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/replay/ReplayPersistenceService.java @@ -87,7 +87,7 @@ public boolean persistUniqueValue(final UniqueValueType type, final String uniqu * Remove expired unique values in the database. */ public void deleteExpiredUniqueValues() { - int expiredCount = uniqueValueRepository.deleteAllByTimestampExpiresBefore(Date.from(Instant.now())); + int expiredCount = uniqueValueRepository.deleteExpiredValues(Date.from(Instant.now())); logger.debug("Removed {} expired unique values", expiredCount); } }