br.com.arsmachina.dao
Interface ReadableDAO<T,K extends Serializable>

Type Parameters:
T - the entity class related to this DAO.
K - the type of the field that represents the entity class' primary key.
All Known Subinterfaces:
DAO<T,K>

public interface ReadableDAO<T,K extends Serializable>

Interface that defines a read-only, generic and generified Data Access Object (DAO) for a given entity class.

Author:
Thiago H. de Paula Figueiredo

Method Summary
 int countAll()
          Returns the total number of objects of this class.
 List<T> findAll()
          Returns the all instances of the related entity class.
 List<T> findAll(int firstResult, int maxResults, SortCriterion... sortingConstraints)
          Returns the all instances of the related entity class, but in a paginated fashion.
 List<T> findByExample(T example)
          Executes a query by example.
 T findById(K id)
          Returns the object with a given primary key value.
 List<T> findByIds(K... ids)
          Returns the objects with some given primary key values.
 SortCriterion[] getDefaultSortCriteria()
          Returns the default SortCriterions to be used to sort the objects lists returned by methods like findAll() and findAll(int, int, SortCriterion...) when no sort constraints are given.
 T reattach(T object)
          Reattaches an object to the persistence context, if there is one.
 void refresh(T object)
          Refreshes an object, overwriting its fields with values coming from the object store.
 

Method Detail

countAll

int countAll()
Returns the total number of objects of this class.

Returns:
an int.

findById

T findById(K id)
Returns the object with a given primary key value.

Parameters:
id - a K.
Returns:
a T.

findByIds

List<T> findByIds(K... ids)
Returns the objects with some given primary key values.

Parameters:
ids - a K array.
Returns:
a List of T.

findAll

List<T> findAll()
Returns the all instances of the related entity class.

Returns:
a List of T.

findByExample

List<T> findByExample(T example)
Executes a query by example.

Parameters:
example - a T.
Returns:
a List of T.

refresh

void refresh(T object)
Refreshes an object, overwriting its fields with values coming from the object store.

Parameters:
object - a T

reattach

T reattach(T object)
Reattaches an object to the persistence context, if there is one. The object store must not be changed. The attached object, which not necessarily is the one passed as a parameter, is returned.

Parameters:
object - a T.
Returns:
object a T.

findAll

List<T> findAll(int firstResult,
                int maxResults,
                SortCriterion... sortingConstraints)
Returns the all instances of the related entity class, but in a paginated fashion.

Parameters:
firstResult - an int with the index of the first object to be returned. The first object has index 0.
maxResults - an int with the maximum number of objects to be returned.
sortingConstraints - an SortCriterion array used to define how the returned list will be sorted.
Returns:
a List of T.

getDefaultSortCriteria

SortCriterion[] getDefaultSortCriteria()
Returns the default SortCriterions to be used to sort the objects lists returned by methods like findAll() and findAll(int, int, SortCriterion...) when no sort constraints are given.

Returns:
a SortCriterion array. It cannot be null.


Copyright © 2008-2009 Thiago H. de Paula Figueiredo. All Rights Reserved.