This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.
Describe the bug
When executing a Cosmos NoSQL query with SUM() using a Spring Data repository a List is returned instead of an int or long
Exception or Stack Trace
java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class java.lang.Long (java.util.ArrayList and java.lang.Long are in module java.base of loader 'bootstrap')
at jdk.proxy3/jdk.proxy3.$Proxy172.findTotalCharactersTranslatedForLastMinute(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
To Reproduce
Create a repository with a method that has a query that uses SUM()
Code Snippet
@Query(value = "SELECT VALUE SUM(c.totalCharacters) FROM c WHERE c.datetime >= @currentMinute")
Long sumTotalCharactersTranslatedForLastMinute(OffsetDateTime currentMinute);
Expected behavior
There should be no exception and a Long (or Long or Integer or int) should be returned. It works with COUNT():
@Query(
value = "SELECT VALUE COUNT(1) FROM f " +
"WHERE ( " +
"EXISTS (SELECT VALUE f FROM f " +
"JOIN c IN f.formLayout.cards " +
"JOIN ow in c.widgets " +
"WHERE ow.includeOneTimeAmounts = true " +
"AND ow.recurringUpsellEnabled = true) " +
"OR EXISTS (SELECT VALUE f FROM f " +
"JOIN w in f.formLayout.widgets " +
"WHERE w.includeOneTimeAmounts = true " +
"AND w.recurringUpsellEnabled = true) " +
") " +
"AND f.environmentId = @environmentId " +
"AND f.archived = false"
)
long countEligibleFormsWithRecurringUpsellEnabledByEnvironmentId(String environmentId);
Setup (please complete the following information):
Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
Describe the bug When executing a Cosmos NoSQL query with SUM() using a Spring Data repository a List is returned instead of an int or long
Exception or Stack Trace
To Reproduce Create a repository with a method that has a query that uses SUM()
Code Snippet
Expected behavior There should be no exception and a Long (or Long or Integer or int) should be returned. It works with
COUNT()
:Setup (please complete the following information):
Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report