-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for total count of filtered task list result (#1512)
* added Query utils to detect if query to be executed concerns a count query, if so skip providing groupBy * switched to single result for count query * added copyright header * removed distinct from list query as this is not necessary * added additional todo for performance improvement * distinct is not necessary when also having a group by --------- Co-authored-by: valtimo-platform[bot] <80107705+valtimo-platform[bot]@users.noreply.github.com>
- Loading branch information
1 parent
50002ca
commit 6b8b81c
Showing
6 changed files
with
64 additions
and
35 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
authorization/src/main/kotlin/com/ritense/authorization/utils/QueryUtils.kt
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright 2015-2024 Ritense BV, the Netherlands. | ||
* | ||
* Licensed under EUPL, Version 1.2 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" basis, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.ritense.authorization.utils | ||
|
||
import jakarta.persistence.criteria.AbstractQuery | ||
import org.hibernate.query.sqm.function.SelfRenderingSqmAggregateFunction | ||
|
||
object QueryUtils { | ||
|
||
fun isCountQuery(query: AbstractQuery<*>) = | ||
query.selection is SelfRenderingSqmAggregateFunction | ||
&& | ||
(query.selection as SelfRenderingSqmAggregateFunction<out Any>).functionName == "count" | ||
} |
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
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
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