Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-1737

SELECT DISTINCT with JOIN results in class cast exception

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • 3.1.0.Final
    • 3.0.1.Final
    • Query
    • None

      Executing the query

      SELECT DISTINCT p.* FROM [inf:patient] AS p JOIN [inf:section] AS s ON ISCHILDNODE(s, p) where s.[inf:name] <> $sectionname
      

      causes a class cast exception if there is more than one patient node matched.

      java.lang.ClassCastException: java.lang.String cannot be cast to org.modeshape.jcr.query.QueryResults$Location
              at org.modeshape.jcr.query.process.DistinctComponent.execute(DistinctComponent.java:56)
              at org.modeshape.jcr.query.process.QueryProcessor.execute(QueryProcessor.java:96)
              at org.modeshape.jcr.query.process.QueryEngine.execute(QueryEngine.java:140)
              at org.modeshape.jcr.query.lucene.LuceneQueryEngine$1.getResults(LuceneQueryEngine.java:151)
              at org.modeshape.jcr.query.JcrQuery.execute(JcrQuery.java:119)
              at au.com.infomedix.modeshapetest.AppTest.testSelectDistinctTwoResults(AppTest.java:122)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
              at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
              at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
              at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
              at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
              at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
              at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
              at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
              at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
              at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
              at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
              at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
              at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
              at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
              at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
              at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
              at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
              at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
              at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
              at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
              at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
              at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
      

      If there is only one node matched then the query works and if the DISTINCT is removed from the query then the query works for multiple nodes matched.

      Test case attached showing the three cases.

              rhauch Randall Hauch (Inactive)
              bwallis42_jira Brian Wallis (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: