Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-22279

ClassCastException when trying to use a QueryParameter with a nested query

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 15.10.10
    • Old Core, Query
    • None
    • Unknown

    Description

      Reproduction steps:

      • Execute the following script in a page:
        {{velocity}}
        $services.query.hql('select nfp.id from DefaultNotificationFilterPreference nfp where nfp.id not in (select nfp2.id from DefaultNotificationFilterPreference nfp2 where nfp2.pageOnly like :myValue)').bindValue('myValue').literal('foo').anyChars().query().execute()
        {{/velocity}}
        

      Expected result:

      • the query should be executed properly (some result might or not appear, it's not relevant here)

      Obtained result:

      • an error is displayed the root cause being:
        Caused by: java.lang.ClassCastException: class org.xwiki.query.internal.DefaultQueryParameter cannot be cast to class java.lang.String (org.xwiki.query.internal.DefaultQueryParameter is in unnamed module of loader org.eclipse.jetty.webapp.WebAppClassLoader @4a83a74a; java.lang.String is in module java.base of loader 'bootstrap')
         at org.hibernate.type.descriptor.java.StringTypeDescriptor.unwrap(StringTypeDescriptor.java:22)
         at org.hibernate.type.descriptor.sql.VarcharTypeDescriptor$1.doBind(VarcharTypeDescriptor.java:46)
         at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:73)
         at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:276)
         at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:271)
         at org.hibernate.param.NamedParameterSpecification.bind(NamedParameterSpecification.java:53)
         at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:682)
         at org.hibernate.loader.Loader.bindPreparedStatement(Loader.java:2150)
         at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2127)
         at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2059)
         at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2037)
         at org.hibernate.loader.Loader.doQuery(Loader.java:956)
         at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:357)
         at org.hibernate.loader.Loader.doList(Loader.java:2868)
         at org.hibernate.loader.Loader.doList(Loader.java:2850)
         at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2682)
         at org.hibernate.loader.Loader.list(Loader.java:2677)
         at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:540)
         at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400)
         at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:218)
         at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1459)
         at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1649)
         at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1617)
         at com.xpn.xwiki.store.hibernate.query.HqlQueryExecutor.lambda$execute$0(HqlQueryExecutor.java:171)
         at com.xpn.xwiki.store.XWikiHibernateBaseStore.execute(XWikiHibernateBaseStore.java:826)
        

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              surli Simon Urli
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated: