net.sf.derquinsej.hib3
Class GeneralDAOImpl

java.lang.Object
  extended by net.sf.derquinsej.hib3.AbstractDAOImpl
      extended by net.sf.derquinsej.hib3.GeneralDAOImpl
All Implemented Interfaces:
DAO, GeneralDAO
Direct Known Subclasses:
RepositoryImpl

public class GeneralDAOImpl
extends AbstractDAOImpl
implements GeneralDAO

Implementation of the General DAO.

Author:
Andres Rodriguez

Constructor Summary
GeneralDAOImpl()
          Constructs the DAO
GeneralDAOImpl(org.hibernate.SessionFactory sessionFactory)
          Constructs the DAO
 
Method Summary
 void delete(Object entity)
          Deletes an entity instance.
<T> void
deleteById(Class<T> type, Serializable id)
          Deletes an entity instance.
<T> List<T>
findAll(Class<T> type)
          Returns all entities of the persistent type.
protected
<T> List<T>
findByCriteria(Class<T> type, org.hibernate.criterion.Criterion... criterion)
          Returns the list of entity instances that matches the provided crtieria.
<T> T
findById(Class<T> type, Serializable id, boolean lock)
          Finds an entity by ID.
protected  org.hibernate.Criteria newCriteria(Class<?> type)
          Returns a new criteria object.
 void save(Object entity)
          Saves an entity.
 void saveOrUpdate(Object entity)
          Saves or updates an entity, depending upon resolution of the unsaved-value checks.
 void update(Object entity)
          Updates an entity.
 
Methods inherited from class net.sf.derquinsej.hib3.AbstractDAOImpl
clear, evict, first, flush, getNamedQuery, getSession, list, list, setSessionFactory, sync, unique, unique
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.derquinsej.hib3.DAO
clear, flush, sync
 

Constructor Detail

GeneralDAOImpl

public GeneralDAOImpl(org.hibernate.SessionFactory sessionFactory)
Constructs the DAO

Parameters:
sessionFactory - Hibernate Session factory.

GeneralDAOImpl

public GeneralDAOImpl()
Constructs the DAO

Method Detail

newCriteria

protected final org.hibernate.Criteria newCriteria(Class<?> type)
Returns a new criteria object.

Parameters:
type - Entity type.
Returns:
A new criteria object.

findByCriteria

protected final <T> List<T> findByCriteria(Class<T> type,
                                           org.hibernate.criterion.Criterion... criterion)
Returns the list of entity instances that matches the provided crtieria.

Parameters:
type - Entity type.
criterion - Search criteria.
Returns:
The results.

delete

public void delete(Object entity)
Description copied from interface: GeneralDAO
Deletes an entity instance.

Specified by:
delete in interface GeneralDAO
Parameters:
entity - Instance to delete.

deleteById

public <T> void deleteById(Class<T> type,
                           Serializable id)
Description copied from interface: GeneralDAO
Deletes an entity instance.

Specified by:
deleteById in interface GeneralDAO
Parameters:
type - Entity type.
id - Id of the instance to delete.

findAll

public <T> List<T> findAll(Class<T> type)
Description copied from interface: GeneralDAO
Returns all entities of the persistent type.

Specified by:
findAll in interface GeneralDAO
Parameters:
type - Entity type.
Returns:
A list with all the instances.

findById

public <T> T findById(Class<T> type,
                      Serializable id,
                      boolean lock)
Description copied from interface: GeneralDAO
Finds an entity by ID.

Specified by:
findById in interface GeneralDAO
Parameters:
type - Entity type.
id - ID.
lock - If the entity shall be locked.
Returns:
The requested entity or null if it is not found.

save

public void save(Object entity)
Description copied from interface: GeneralDAO
Saves an entity.

Specified by:
save in interface GeneralDAO
Parameters:
entity - Entity to save.

saveOrUpdate

public void saveOrUpdate(Object entity)
Description copied from interface: GeneralDAO
Saves or updates an entity, depending upon resolution of the unsaved-value checks.

Specified by:
saveOrUpdate in interface GeneralDAO
Parameters:
entity - Entity to persist.

update

public void update(Object entity)
Description copied from interface: GeneralDAO
Updates an entity.

Specified by:
update in interface GeneralDAO
Parameters:
entity - Entity to update.


Copyright © 2011. All Rights Reserved.