br.com.arsmachina.controller
Interface ReadableController<T,K extends Serializable>

Type Parameters:
T - the entity class related to this controller.
K - the type of the field that represents the entity class' primary key.
All Known Subinterfaces:
Controller<T,K>
All Known Implementing Classes:
ControllerImpl, ReadableControllerImpl

public interface ReadableController<T,K extends Serializable>

Interface that defines a read-only, generic and generified controller 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, br.com.arsmachina.dao.SortCriterion... sortConstraints)
          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.
 T reattach(T object)
          Reattaches an object to the persistence context, if there is one.
 

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.

findAll

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

Returns:
a List of 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.

findByExample

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

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

findAll

List<T> findAll(int firstResult,
                int maxResults,
                br.com.arsmachina.dao.SortCriterion... sortConstraints)
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.
sortConstraints - an SortConstraint array used to define how the returned list will be sorted.
Returns:
a List of 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.


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