Class QueryManagerScriptService

  • All Implemented Interfaces:
    org.xwiki.script.service.ScriptService

    @Component
    @Named("query")
    @Singleton
    public class QueryManagerScriptService
    extends Object
    implements org.xwiki.script.service.ScriptService
    Provides Query Manager-specific Scripting APIs.
    Since:
    2.4M2
    Version:
    $Id: 94e5b557e7b35fb953ceb98da5fc2d593aff4b08 $
    • Constructor Detail

      • QueryManagerScriptService

        public QueryManagerScriptService()
    • Method Detail

      • xwql

        public Query xwql​(String statement)
                   throws QueryException
        Shortcut for writing a XWQL query.
        Parameters:
        statement - the XWQL statement for the query
        Returns:
        the Query object, ready to be executed
        Throws:
        QueryException - if any errors
      • hql

        public Query hql​(String statement)
                  throws QueryException
        Shortcut for writing a HQL query.
        Parameters:
        statement - the HQL statement for the query
        Returns:
        the Query object, ready to be executed
        Throws:
        QueryException - if any errors
      • createQuery

        public Query createQuery​(String statement,
                                 String language)
                          throws QueryException
        Create a Query for the given statement and language.
        Parameters:
        statement - the query statement
        language - language of the query. Must be a supported language.
        Returns:
        the Query object
        Throws:
        QueryException - if language is not supported
      • parameter

        public QueryParameter parameter()
        Allow creating query parameters. For example:
        
         #set ($queryParams = [])
         #set ($whereQueryPart = "${whereQueryPart} AND doc.space = ?")
         #set ($discard = $queryParams.add($services.query.parameter().literal($request.space)))
         
        Returns:
        the Query parameter object, see QueryParameter for more details on how to create the parameter content
        Since:
        8.4.5, 9.3RC1