com.ferri.persistence.dao.commons
Interface GenericBaseDAO<E extends BaseVO,PK extends Serializable>

All Superinterfaces:
Initializable
All Known Subinterfaces:
AdministradorDAO, ClientDAO, ConstantsDAO, ContadorDAO, ContracteDAO, EstatDAO, FacturaDAO, GestoriaDAO, IntervencioDAO, PressupostDAO, TipusClientDAO, TipusPeriodeDAO
All Known Implementing Classes:
AdministradorDAOImpl, BaseAdministradorDAO, BaseClientDAO, BaseConstantsDAO, BaseContadorDAO, BaseContracteDAO, BaseEstatDAO, BaseFacturaDAO, BaseGestoriaDAO, BaseIntervencioDAO, BasePressupostDAO, BaseTipusClientDAO, BaseTipusPeriodeDAO, ClientDAOImpl, ConstantsDAOImpl, ContadorDAOImpl, ContracteDAOImpl, EstatDAOImpl, FacturaDAOImpl, GenericBaseDAOImpl, GestoriaDAOImpl, IntervencioDAOImpl, PressupostDAOImpl, TipusClientDAOImpl, TipusPeriodeDAOImpl

public interface GenericBaseDAO<E extends BaseVO,PK extends Serializable>
extends Initializable

Author:
dferri

Field Summary
static String ORDER_BY
           
static String SEPARATOR_COMMA
           
static String SEPARATOR_DOT
           
 
Method Summary
 Collection<E> create(Collection<E> entities)
          Persist the given transient collection instance, first assigning a generated identifier.
 PK create(E entity)
          Persist the given transient instance, first assigning a generated identifier.
 Collection<E> find(String queryString, Object[] values)
          find Entity instances.
 Collection<E> findByCriteria(org.hibernate.criterion.DetachedCriteria criteria)
          findByExample Entity instances.
 Collection<E> findByExample(E entity)
          findByExample Entity instances.
 org.hibernate.criterion.DetachedCriteria getCriteria()
          Obtain a criteria for the entity class
 String getQueryOrderedBy(String entityName, String query, org.hibernate.criterion.Order... orders)
          Contruct order by from entityName, query and OrderOrder
 E load(PK Id)
          Loads a Entity instance by identifier.
 Collection<E> loadAll()
          Return all objects related to the implementation of this DAO with no filter.
 Collection<E> loadAllOrderBy(org.hibernate.criterion.Order... orders)
          Return all objects related to the implementation of this DAO with no filter and ordered by orders.
 Collection<E> loadAllOrderby(String propertyName, Boolean ascending)
          Return all objects related to the implementation of this DAO with no filter, ordered by propertyName and ascending.
 void remove(Collection<E> entities)
          Removes all entities in the given entities collection.
 void remove(E entity)
          Remove a persistent instance from the datastore.
 void removeByPk(PK id)
          Remove a persistent instance from the datastore.
 void save(E entity)
          Save the persistent state associated with the given identifier.
 void saveOrUpdate(Collection<E> entities)
          saveOrUpdate the persistent collection state associated with the given identifier.
 void saveOrUpdate(E entity)
          saveOrUpdate the persistent state associated with the given identifier.
 void update(E entity)
          Update a persistent instance from the datastore.
 
Methods inherited from interface com.ferri.core.behaviors.Initializable
initialize
 

Field Detail

ORDER_BY

static final String ORDER_BY
See Also:
Constant Field Values

SEPARATOR_COMMA

static final String SEPARATOR_COMMA
See Also:
Constant Field Values

SEPARATOR_DOT

static final String SEPARATOR_DOT
See Also:
Constant Field Values
Method Detail

load

E load(PK Id)
Loads a Entity instance by identifier.

Parameters:
key - the identifier
Returns:
Entity the requested instance.

loadAll

Collection<E> loadAll()
Return all objects related to the implementation of this DAO with no filter.

Returns:
Collection all non filtered objects.

create

PK create(E entity)
Persist the given transient instance, first assigning a generated identifier. (Or using the current value of the identifier property if the assigned generator is used.)

Parameters:
entity - a transient instance of a persistent class.
Returns:
the class identifier.

create

Collection<E> create(Collection<E> entities)
Persist the given transient collection instance, first assigning a generated identifier. (Or using the current value of the identifier property if the assigned generator is used.)

Parameters:
entities - the collection to persist.
Returns:
Collection the created entities.

save

void save(E entity)
Save the persistent state associated with the given identifier. An exception is thrown if there is a persistent instance with the same identifier in the current session.

Parameters:
entity - a transient instance containing saved Or Updated state.

update

void update(E entity)
Update a persistent instance from the datastore. The argument may be an instance associated with the receiving Session or a transient instance with an identifier associated with existing persistent state.

Parameters:
entity - the instance to be updated.

saveOrUpdate

void saveOrUpdate(E entity)
saveOrUpdate the persistent state associated with the given identifier. An exception is thrown if there is a persistent instance with the same identifier in the current session.

Parameters:
entity - a transient instance containing saved Or Updated state.

saveOrUpdate

void saveOrUpdate(Collection<E> entities)
saveOrUpdate the persistent collection state associated with the given identifier. An exception is thrown if there is a persistent instance with the same identifier in the current session.

Parameters:
entities - the collection to saveOrUpdate.

removeByPk

void removeByPk(PK id)
Remove a persistent instance from the datastore. The argument may be an instance associated with the receiving Session or a transient instance with an identifier associated with existing persistent state.

Parameters:
id - the instance ID to be removed.

remove

void remove(E entity)
Remove a persistent instance from the datastore. The argument may be an instance associated with the receiving Session or a transient instance with an identifier associated with existing persistent state.

Parameters:
entity - the instance to be removed.

remove

void remove(Collection<E> entities)
Removes all entities in the given entities collection.

Parameters:
entities - the collection remove.

find

Collection<E> find(String queryString,
                   Object[] values)
find Entity instances.

Parameters:
queryString -
values -
Returns:
Collection all filtered objects.

findByExample

Collection<E> findByExample(E entity)
findByExample Entity instances.

Parameters:
entity - the identifier
Returns:
Collection all filtered objects.

findByCriteria

Collection<E> findByCriteria(org.hibernate.criterion.DetachedCriteria criteria)
findByExample Entity instances.

Parameters:
entity - the identifier
Returns:
Collection all filtered objects.

getCriteria

org.hibernate.criterion.DetachedCriteria getCriteria()
Obtain a criteria for the entity class

Returns:
a criteria for the entity class.

loadAllOrderBy

Collection<E> loadAllOrderBy(org.hibernate.criterion.Order... orders)
Return all objects related to the implementation of this DAO with no filter and ordered by orders.

Returns:
Collection all non filtered objects.

loadAllOrderby

Collection<E> loadAllOrderby(String propertyName,
                             Boolean ascending)
Return all objects related to the implementation of this DAO with no filter, ordered by propertyName and ascending.

Returns:
Collection all non filtered objects.

getQueryOrderedBy

String getQueryOrderedBy(String entityName,
                         String query,
                         org.hibernate.criterion.Order... orders)
Contruct order by from entityName, query and OrderOrder

Parameters:
entityName - the entity name
query - the query
orders - the orders
Returns:
the resulted orderby