ENT-10756: Use normal select count query for totalStatesAvailable (#7492)

Some DBs do not like the use of `distinct` in the count query for the `Page.totalStatesAvailable` result. It turns out it's not needed anyway and a non-distinct select count works as well.
This commit is contained in:
Shams Asari 2023-09-08 15:55:23 +01:00 committed by GitHub
parent fad7fcbd11
commit fb4247d5c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -771,7 +771,7 @@ class NodeVaultService(
private fun <T : ContractState> queryTotalStateCount(criteria: QueryCriteria, contractStateType: Class<out T>): Long {
val (criteriaQuery, criteriaParser) = buildCriteriaQuery<Long>(criteria, contractStateType, null)
criteriaQuery.select(criteriaBuilder.countDistinct(criteriaParser.vaultStates))
criteriaQuery.select(criteriaBuilder.count(criteriaParser.vaultStates))
val query = getSession().createQuery(criteriaQuery)
return query.singleResult
}