Closed kumar842 closed 2 years ago
Hello,
I have create a new version containing a correction.
At the end it was surprising that a an Integer is returned even so the corresponding CriteriaBuilder
method indicates that count returns a Long: Expression<Long> countDistinct(Expression<?> x);
In case you still face a problem, reopen the issue.
API http://localhost:8091/v1/Orders/$count http://localhost:8091/v1/Orders?$count=true
Error:
{ "error": { "code": null, "message": "class java.lang.Integer cannot be cast to class java.lang.Long" } }
In MS SQL server, the return type of the count function is int.
JPAJoinQuery.java > CountResults() method will be called in case of /orders/$count or /orders?$count=true. This calls getSingleResult() (line no: 104). So, expected return type is Long.
TypeQueryImpl.java > getSingleResult() calls getResultList()(line no: 185), which returns List instead of List<Long)
because the select count() query returns List.
Can you please help or guide here.