Interface CannedQueryDAO

  • All Known Implementing Classes:
    AbstractCannedQueryDAOImpl, CannedQueryDAOImpl

    public interface CannedQueryDAO
    DAO services for general-use database canned queries. Note that this is specifically targeted at low-level queries to the persistance layer.
    Since:
    3.5
    Author:
    Derek Hulley
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static interface  CannedQueryDAO.ResultHandler<R>
      A simple, typed results handler.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.Long executeCountQuery​(java.lang.String sqlNamespace, java.lang.String queryName, java.lang.Object parameterObj)
      Execute a count(*)-style query returning a count value.
      <R> java.util.List<R> executeQuery​(java.lang.String sqlNamespace, java.lang.String queryName, java.lang.Object parameterObj, int offset, int limit)
      Execute a query that returns one or more results.
      <R> void executeQuery​(java.lang.String sqlNamespace, java.lang.String queryName, java.lang.Object parameterObj, int offset, int limit, CannedQueryDAO.ResultHandler<R> handler)
      Execute a query that returns one or more results, processing the results using a handler.
      <R> R executeQueryUnique​(java.lang.String sqlNamespace, java.lang.String queryName, java.lang.Object parameterObj)
      Execute a query that returns exactly one result.
    • Method Detail

      • executeCountQuery

        java.lang.Long executeCountQuery​(java.lang.String sqlNamespace,
                                         java.lang.String queryName,
                                         java.lang.Object parameterObj)
        Execute a count(*)-style query returning a count value. The implementation will ensure that null is substituted with 0, if required.

        All exceptions can be safely caught and handled as required.

        Parameters:
        sqlNamespace - the query namespace (defined by config file) e.g. alfresco.query.usage
        queryName - the name of the query e.g. select_userCount
        parameterObj - the values to drive the selection (may be null if not required)
        Returns:
        a non-null count
        Throws:
        QueryException - if the query returned multiple results
      • executeQueryUnique

        <R> R executeQueryUnique​(java.lang.String sqlNamespace,
                                 java.lang.String queryName,
                                 java.lang.Object parameterObj)
        Execute a query that returns exactly one result. The assumption is that the parameters provided uniquely identify the object.
        Type Parameters:
        R - the return value's type
        Parameters:
        sqlNamespace - the query namespace (defined by config file) e.g. alfresco.query.usage
        queryName - the name of the query e.g. select_userCount
        parameterObj - the values to drive the selection (may be null if not required)
        Returns:
        the unique result (never null)
        Throws:
        java.lang.IllegalArgumentException - concurrency-related exception if a single object was not found
      • executeQuery

        <R> java.util.List<R> executeQuery​(java.lang.String sqlNamespace,
                                           java.lang.String queryName,
                                           java.lang.Object parameterObj,
                                           int offset,
                                           int limit)
        Execute a query that returns one or more results.
        Type Parameters:
        R - the return value's type
        Parameters:
        sqlNamespace - the query namespace (defined by config file) e.g. alfresco.query.usage
        queryName - the name of the query e.g. select_userCount
        parameterObj - the values to drive the selection (may be null if not required)
        offset - the number of results to skip
        limit - the maximum number of results to retrieve or Integer.MAX_VALUE for no limit
        Returns:
        the list of results
      • executeQuery

        <R> void executeQuery​(java.lang.String sqlNamespace,
                              java.lang.String queryName,
                              java.lang.Object parameterObj,
                              int offset,
                              int limit,
                              CannedQueryDAO.ResultHandler<R> handler)
        Execute a query that returns one or more results, processing the results using a handler.
        Type Parameters:
        R - the return value's type
        Parameters:
        sqlNamespace - the query namespace (defined by config file) e.g. alfresco.query.usage
        queryName - the name of the query e.g. select_userCount
        parameterObj - the values to drive the selection (may be null if not required)
        offset - the number of results to skip
        limit - the maximum number of results to retrieve or Integer.MAX_VALUE for no limit