Files
alfresco-community-repo/source/java/org/alfresco/repo/domain/query/CannedQueryDAO.java
Raluca Munteanu 8674e2bfc8 Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)
125603 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2)
      125484 slanglois: MNT-16155 Update source headers - remove old Copyrights from Java and JSP dource files


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@125781 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2016-04-26 12:48:49 +00:00

105 lines
4.8 KiB
Java

package org.alfresco.repo.domain.query;
import java.util.List;
/**
* DAO services for general-use database canned queries. Note that this is specifically targeted
* at low-level queries to the persistance layer.
*
* @author Derek Hulley
* @since 3.5
*/
public interface CannedQueryDAO
{
/*
* This interface looks very much like SqlSessionTemplate; this is not accidental.
* However, the use of generics and the ability to trace all general SQL queries through
* an Alfresco API make it useful. Additionally, there are specific checks done in the
* implementation to insulate the client from some common problems.
*/
/**
* Execute a <b>count(*)</b>-style query returning a count value. The implementation
* will ensure that <tt>null</tt> is substituted with <tt>0</tt>, if required.
* <p>
* All exceptions can be safely caught and handled as required.
*
* @param sqlNamespace the query namespace (defined by config file) e.g. <b>alfresco.query.usage</b>
* @param queryName the name of the query e.g. <b>select_userCount</b>
* @param parameterObj the values to drive the selection (may be <tt>null</tt> if not required)
* @return a non-null count
*
* @throws QueryException if the query returned multiple results
*/
Long executeCountQuery(String sqlNamespace, String queryName, Object parameterObj);
/**
* Execute a query that returns exactly one result. The assumption is that the parameters provided
* uniquely identify the object.
*
* @param <R> the return value's type
* @param sqlNamespace the query namespace (defined by config file) e.g. <b>alfresco.query.usage</b>
* @param queryName the name of the query e.g. <b>select_userCount</b>
* @param parameterObj the values to drive the selection (may be <tt>null</tt> if not required)
* @return the unique result (never <tt>null</tt>)
* @throws IllegalArgumentException concurrency-related exception if a single object was not found
*/
<R> R executeQueryUnique(String sqlNamespace, String queryName, Object parameterObj);
/**
* Execute a query that returns one or more results.
*
* @param <R> the return value's type
* @param sqlNamespace the query namespace (defined by config file) e.g. <b>alfresco.query.usage</b>
* @param queryName the name of the query e.g. <b>select_userCount</b>
* @param parameterObj the values to drive the selection (may be <tt>null</tt> if not required)
* @param offset the number of results to skip
* @param limit the maximum number of results to retrieve or <code>Integer.MAX_VALUE</code>
* for no limit
* @return the list of results
*/
<R> List<R> executeQuery(
String sqlNamespace, String queryName, Object parameterObj,
int offset, int limit);
/**
* Execute a query that returns one or more results, processing the results using a handler.
*
* @param <R> the return value's type
* @param sqlNamespace the query namespace (defined by config file) e.g. <b>alfresco.query.usage</b>
* @param queryName the name of the query e.g. <b>select_userCount</b>
* @param parameterObj the values to drive the selection (may be <tt>null</tt> if not required)
* @param offset the number of results to skip
* @param limit the maximum number of results to retrieve or <code>Integer.MAX_VALUE</code>
* for no limit
*/
<R> void executeQuery(
String sqlNamespace,
String queryName,
Object parameterObj,
int offset,
int limit,
ResultHandler<R> handler);
/**
* A simple, typed results handler.
*
* @author Derek Hulley
* @since 4.0
*
* @param <R> the type of the result
*/
public interface ResultHandler<R>
{
/**
* Allow implementations to process a result. Note that the interface contract will
* be met, but internally the querying mechanism <i>might not</i> be able to optimise out
* all result fetching.
*
* @return <tt>true</tt> if more results are required or <tt>false</tt> to
* terminate result fetching.
*/
boolean handleResult(R result);
}
}