Class HqlQueryExecutor

  • All Implemented Interfaces:
    org.xwiki.component.phase.Initializable, QueryExecutor

    @Component
    @Named("hql")
    @Singleton
    public class HqlQueryExecutor
    extends Object
    implements QueryExecutor, org.xwiki.component.phase.Initializable
    QueryExecutor implementation for Hibernate Store.
    Since:
    1.6M1
    Version:
    $Id: 6409d9ec7c29ec2314c973073bda0cffdc2d2853 $
    • Constructor Detail

      • HqlQueryExecutor

        public HqlQueryExecutor()
    • Method Detail

      • initialize

        public void initialize()
                        throws org.xwiki.component.phase.InitializationException
        Specified by:
        initialize in interface org.xwiki.component.phase.Initializable
        Throws:
        org.xwiki.component.phase.InitializationException
      • isSafeSelect

        protected static boolean isSafeSelect​(String statementString)
        Parameters:
        statementString - the statement to evaluate
        Returns:
        true if the select is allowed for user without PR
      • filterQuery

        protected Query filterQuery​(Query query)
      • createQuery

        protected <T> org.hibernate.query.Query<T> createQuery​(org.hibernate.Session session,
                                                               Query query)
        Create an Hibernate query from an XWiki Query.
        Type Parameters:
        T - the type to return
        Parameters:
        session - the Hibernate session
        query - the query to convert
        Returns:
        the Hibernate query
      • createHibernateQuery

        @Deprecated(since="13.10.6")
        protected <T> org.hibernate.query.Query<T> createHibernateQuery​(org.hibernate.Session session,
                                                                        Query query)
        Deprecated.
        since 13.10.6, 14.4, use createQuery(Session, Query) instead
      • completeShortFormStatement

        protected String completeShortFormStatement​(String statement)
        Append the required select clause to HQL short query statements. Short statements are the only way for users without programming rights to perform queries. Such statements can be for example:
        • , BaseObject obj where doc.fullName=obj.name and obj.className='XWiki.MyClass'
        • where doc.creationDate > '2008-01-01'
        Parameters:
        statement - the statement to complete if required.
        Returns:
        the complete statement if it had to be completed, the original one otherwise.
      • populateParameters

        protected void populateParameters​(org.hibernate.query.Query<?> hquery,
                                          Query query)
        Parameters:
        hquery - query to populate parameters
        query - query from to populate.
      • setNamedParameter

        protected void setNamedParameter​(org.hibernate.query.Query<?> query,
                                         String name,
                                         Object value)
        Sets the value of the specified named parameter, taking into account the type of the given value.
        Parameters:
        query - the query to set the parameter for
        name - the parameter name
        value - the non-null parameter value
      • getContext

        protected XWikiContext getContext()
        Returns:
        XWiki Context