Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-6760

Comparing a sum of an attribute fails with ClassCastException

XMLWordPrintable

      The following query (in the context of QueryDslConditionsTest)

      public void testSum2() throws Exception {
          QueryFactory qf = getQueryFactory();
          Query q = qf.from(getModelFactory().getUserImplClass())
              .select(sum("age"))
              .groupBy("name")
              .having(sum("age")).gt(50000).toBuilder()
              .build();
          List<Object[]> list = q.list();
      }
      

      fails with

      java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
      	at java.lang.Integer.compareTo(Integer.java:52)
      	at org.infinispan.objectfilter.impl.util.Interval.contains(Interval.java:92)
      	at org.infinispan.objectfilter.impl.predicateindex.IntervalCondition.match(IntervalCondition.java:19)
      	at org.infinispan.objectfilter.impl.predicateindex.IntervalCondition.match(IntervalCondition.java:9)
      	at org.infinispan.objectfilter.impl.predicateindex.Predicate.match(Predicate.java:37)
      	at org.infinispan.objectfilter.impl.predicateindex.Predicates.notifyMatchingSubscribers(Predicates.java:118)
      	at org.infinispan.objectfilter.impl.predicateindex.AttributeNode.processValue(AttributeNode.java:114)
      	at org.infinispan.objectfilter.impl.predicateindex.RowMatcherEvalContext.processAttributes(RowMatcherEvalContext.java:30)
      	at org.infinispan.objectfilter.impl.predicateindex.MatcherEvalContext.process(MatcherEvalContext.java:129)
      	at org.infinispan.objectfilter.impl.ObjectFilterImpl.filter(ObjectFilterImpl.java:213)
      	at org.infinispan.query.dsl.embedded.impl.HybridQuery$1.updateNext(HybridQuery.java:80)
      	at org.infinispan.query.dsl.embedded.impl.HybridQuery$1.hasNext(HybridQuery.java:59)
      	at org.infinispan.query.dsl.embedded.impl.BaseEmbeddedQuery.listInternal(BaseEmbeddedQuery.java:66)
      	at org.infinispan.query.dsl.embedded.impl.BaseEmbeddedQuery.list(BaseEmbeddedQuery.java:57)
      	at org.infinispan.query.dsl.embedded.impl.DelegatingQuery.list(DelegatingQuery.java:49)
      	at org.infinispan.query.dsl.embedded.QueryDslConditionsTest.testSum2(QueryDslConditionsTest.java:2001)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
      	at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
      	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
      	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
      	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
      	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
      	at org.testng.TestRunner.privateRun(TestRunner.java:767)
      	at org.testng.TestRunner.run(TestRunner.java:617)
      	at org.testng.SuiteRunner.runTest(SuiteRunner.java:348)
      	at org.testng.SuiteRunner.access$000(SuiteRunner.java:38)
      	at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:382)
      	at org.testng.internal.thread.ThreadUtil$2.call(ThreadUtil.java:64)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      

      Using

      .having(sum("age")).gt(new Long(50000)).toBuilder()

      doesn't have any effect.

              anistor Adrian Nistor (Inactive)
              jmarkos Jakub Markos (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: