-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1326 from /issues/1308-oracle-distinct
Fix #1308: Operation list fails on Oracle (backport)
- Loading branch information
Showing
3 changed files
with
50 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ | |
* Database repository for the operations. | ||
* | ||
* @author Petr Dvorak, [email protected] | ||
* @implSpec Oracle does not support {@code DISTINCT} on {@code CLOB} so subselects have to be used. | ||
*/ | ||
@Repository | ||
public interface OperationRepository extends CrudRepository<OperationEntity, String> { | ||
|
@@ -48,32 +49,40 @@ public interface OperationRepository extends CrudRepository<OperationEntity, Str | |
Optional<OperationEntity> findOperation(String operationId); | ||
|
||
@Query(""" | ||
SELECT DISTINCT o FROM OperationEntity o INNER JOIN o.applications a | ||
WHERE o.userId = :userId | ||
AND a.id in :applicationIds | ||
AND (:activationId IS NULL OR o.activationId IS NULL OR o.activationId = :activationId) | ||
AND (:activationFlags IS NULL OR o.activationFlag IS NULL OR o.activationFlag IN :activationFlags) | ||
ORDER BY o.timestampCreated DESC | ||
""") | ||
SELECT o FROM OperationEntity o WHERE o.id IN (SELECT o.id FROM OperationEntity o INNER JOIN o.applications a | ||
WHERE o.userId = :userId | ||
AND a.id in :applicationIds | ||
AND (:activationId IS NULL OR o.activationId IS NULL OR o.activationId = :activationId) | ||
AND (:activationFlags IS NULL OR o.activationFlag IS NULL OR o.activationFlag IN :activationFlags)) | ||
ORDER BY o.timestampCreated DESC | ||
""") | ||
Stream<OperationEntity> findAllOperationsForUser(String userId, List<String> applicationIds, String activationId, List<String> activationFlags, final Pageable pageable); | ||
|
||
@Query(""" | ||
SELECT DISTINCT o FROM OperationEntity o INNER JOIN o.applications a | ||
WHERE o.userId = :userId | ||
AND a.id IN :applicationIds | ||
AND o.status = io.getlime.security.powerauth.app.server.database.model.enumeration.OperationStatusDo.PENDING | ||
AND (:activationId IS NULL OR o.activationId IS NULL OR o.activationId = :activationId) | ||
AND (:activationFlags IS NULL OR o.activationFlag IS NULL OR o.activationFlag IN :activationFlags) | ||
ORDER BY o.timestampCreated DESC | ||
""") | ||
SELECT o FROM OperationEntity o WHERE o.id IN (SELECT o.id FROM OperationEntity o INNER JOIN o.applications a | ||
WHERE o.userId = :userId | ||
AND a.id IN :applicationIds | ||
AND o.status = io.getlime.security.powerauth.app.server.database.model.enumeration.OperationStatusDo.PENDING | ||
AND (:activationId IS NULL OR o.activationId IS NULL OR o.activationId = :activationId) | ||
AND (:activationFlags IS NULL OR o.activationFlag IS NULL OR o.activationFlag IN :activationFlags)) | ||
ORDER BY o.timestampCreated DESC | ||
""") | ||
Stream<OperationEntity> findPendingOperationsForUser(String userId, List<String> applicationIds, String activationId, List<String> activationFlags, final Pageable pageable); | ||
|
||
@Query("SELECT DISTINCT o FROM OperationEntity o INNER JOIN o.applications a WHERE o.externalId = :externalId AND a.id IN :applicationIds ORDER BY o.timestampCreated DESC") | ||
@Query(""" | ||
SELECT o FROM OperationEntity o WHERE o.id IN (SELECT o.id FROM OperationEntity o INNER JOIN o.applications a | ||
WHERE o.externalId = :externalId | ||
AND a.id IN :applicationIds) | ||
ORDER BY o.timestampCreated DESC | ||
""") | ||
Stream<OperationEntity> findOperationsByExternalId(String externalId, List<String> applicationIds, final Pageable pageable); | ||
|
||
@Query("SELECT DISTINCT o FROM OperationEntity o " + | ||
"WHERE o.timestampExpires < :timestamp AND o.status = io.getlime.security.powerauth.app.server.database.model.enumeration.OperationStatusDo.PENDING " + | ||
"ORDER BY o.timestampCreated") | ||
@Query(""" | ||
SELECT o FROM OperationEntity o | ||
WHERE o.timestampExpires < :timestamp | ||
AND o.status = io.getlime.security.powerauth.app.server.database.model.enumeration.OperationStatusDo.PENDING | ||
ORDER BY o.timestampCreated | ||
""") | ||
Stream<OperationEntity> findExpiredPendingOperations(Date timestamp); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters