info.joseluismartin.dao.hibernate
Class HibernateExecutable

java.lang.Object
  extended by info.joseluismartin.dao.hibernate.HibernateExecutable

public class HibernateExecutable
extends Object

Wrapper for common methods in Query and Criteria interfaces

Author:
Jose Luis Martin - (jlm@joseluismartin.info)

Field Summary
static String LIST
           
static String SET_FIRST_RESULT
           
static String SET_MAX_RESULTS
           
static String SET_RESULT_TRANSFORMER
           
static String UNIQUE_RESULT
           
 
Constructor Summary
HibernateExecutable(Criteria criteria)
           
HibernateExecutable(Query query)
           
 
Method Summary
 HibernateExecutable HibersetResultTransformer(ResultTransformer transformer)
          Set a strategy for handling the query results.
 List list()
          Return the query results as a List.
 HibernateExecutable setFirstResult(int firstResult)
          Set the first row to retrieve.
 HibernateExecutable setMaxResults(int maxResults)
          Set the maximum number of rows to retrieve.
 Object uniqueResult()
          Convenience method to return a single instance that matches the query, or null if the query returns no results.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LIST

public static final String LIST
See Also:
Constant Field Values

UNIQUE_RESULT

public static final String UNIQUE_RESULT
See Also:
Constant Field Values

SET_MAX_RESULTS

public static final String SET_MAX_RESULTS
See Also:
Constant Field Values

SET_FIRST_RESULT

public static final String SET_FIRST_RESULT
See Also:
Constant Field Values

SET_RESULT_TRANSFORMER

public static final String SET_RESULT_TRANSFORMER
See Also:
Constant Field Values
Constructor Detail

HibernateExecutable

public HibernateExecutable(Criteria criteria)

HibernateExecutable

public HibernateExecutable(Query query)
Method Detail

list

public List list()
          throws HibernateException
Return the query results as a List. If the query contains multiple results pre row, the results are returned in an instance of Object[].

Returns:
the result list
Throws:
HibernateException

uniqueResult

public Object uniqueResult()
                    throws HibernateException
Convenience method to return a single instance that matches the query, or null if the query returns no results.

Returns:
the single result or null
Throws:
NonUniqueResultException - if there is more than one matching result
HibernateException

setMaxResults

public HibernateExecutable setMaxResults(int maxResults)
Set the maximum number of rows to retrieve. If not set, there is no limit to the number of rows retrieved.

Parameters:
maxResults - the maximum number of rows

setFirstResult

public HibernateExecutable setFirstResult(int firstResult)
Set the first row to retrieve. If not set, rows will be retrieved beginnning from row 0.

Parameters:
firstResult - a row number, numbered from 0

HibersetResultTransformer

public HibernateExecutable HibersetResultTransformer(ResultTransformer transformer)
Set a strategy for handling the query results. This can be used to change "shape" of the query result.

Parameters:
transformer - The transformer to apply
Returns:
this (for method chaining)


Copyright © 2012 JDAL. All Rights Reserved.