Details
-
Bug
-
Resolution: Fixed
-
Major
-
2.2.2
-
None
-
regression
-
Trivial
-
Description
I'm trying to count the documents from a given space. The following code fails:
{{velocity}} $xwiki.countDocuments("where doc.space = ?", ["MySpace"]) {{/velocity}}
with this exception:
Caused by: com.xpn.xwiki.XWikiException: Error number 3223 in 3: Exception while searching documents with SQL [select count(distinct doc.fullName) from XWikiDocument as doc where (doc.hidden <> true or doc.hidden is null) and doc.space = ?] Wrapped Exception: java.lang.Long cannot be cast to [Ljava.lang.Object; at com.xpn.xwiki.store.XWikiHibernateStore.searchGenericInternal(XWikiHibernateStore.java:2470) at com.xpn.xwiki.store.XWikiHibernateStore.countDocuments(XWikiHibernateStore.java:2401) at com.xpn.xwiki.store.XWikiCacheStore.countDocuments(XWikiCacheStore.java:601) at com.xpn.xwiki.api.XWiki.countDocuments(XWiki.java:599)
The following code works fine:
{{velocity}}
$xwiki.countDocuments("where doc.space = 'MySpace")
{{/velocity}}
but I prefer to inject the HQL parameters in a safe way.