Details
-
Improvement
-
Resolution: Unresolved
-
Minor
-
None
-
12.4
-
None
-
Unknown
-
Description
If you don't specify the select part,
select doc.fullname from Document doc
is concatenated to the passed query.
The problem is when you are adding a different select at the beginning of the query, that doesn't contain 'doc.fullname' column, since this will make the count filter to not work and simply return -1
Here is an example that selects only attachments filename from a document and where $query.count() returns -1
#set ($query = $services.query.hql("select attachment.filename from XWikiAttachment attachment, XWikiDocument doc where doc.id = attachment.docId and doc.id = :docId order by lower(attachment.filename) asc, attachment.filename asc")) #set ($discard = $query.bindValue('docId', $doc.getId())) #set ($attachments = $query.execute()) $query.count()