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
- is related to
-
XWIKI-22278 DefaultQueryParameter should be usable for any variable and not only for like condition
- Open