fjtirado commented on code in PR #2196:
URL:
https://github.com/apache/incubator-kie-kogito-apps/pull/2196#discussion_r1971389238
##########
data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/JPAQuery.java:
##########
@@ -195,4 +191,21 @@ private List<Predicate>
getRecursivePredicate(AttributeFilter<?> filter, Root<E>
.collect(toList());
}
+ @Override
+ public long count() {
+ CriteriaBuilder builder =
repository.getEntityManager().getCriteriaBuilder();
+ CriteriaQuery<Long> criteriaQuery = builder.createQuery(Long.class);
+ Root<E> root = criteriaQuery.from(entityClass);
+ criteriaQuery.select(builder.count(root));
+ addWhere(builder, criteriaQuery, root);
+ return
repository.getEntityManager().createQuery(criteriaQuery).getSingleResult();
Review Comment:
Added a new test that proof that getSingleResult return 0 if there are not
items, so nothing to change here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]