This issue has been created
There is 1 comment.
 
 
XWiki Platform / cid:jira-generated-image-avatar-de0e8d87-2d66-4226-84c2-05c8e28ff41d XWIKI-22279 Open

ClassCastException when trying to use a QueryParameter with a nested query

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-937d1db2-a3b0-4a40-84d4-f279d2a85e1b Simon Urli created this issue on 19/Jun/24 15:55
 
Summary: ClassCastException when trying to use a QueryParameter with a nested query
Issue Type: cid:jira-generated-image-avatar-de0e8d87-2d66-4226-84c2-05c8e28ff41d Bug
Affects Versions: 15.10.10
Assignee: Unassigned
Components: Query
Created: 19/Jun/24 15:55
Priority: cid:jira-generated-image-static-major-18ff6e57-ce14-4251-be53-5b3e2a4bc35e Major
Reporter: Simon Urli
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)
    
 
 

1 comment

 
cid:jira-generated-image-avatar-937d1db2-a3b0-4a40-84d4-f279d2a85e1b Simon Urli on 19/Jun/24 15:55
 

For some reason the nested query is not visited so the parameters are never found.