org.iternine.jeppetto.dao
Interface GenericDAO<T,ID>

Type Parameters:
T - Type of entity
ID - ID type for the entity.
All Known Subinterfaces:
AccessControlDAO<T,ID>, QueryModelDAO<T,ID>

public interface GenericDAO<T,ID>

A GenericDAO is the root interface for DAOs that fit within the Jeppetto framework. This defines base functionality such as finding a specific entity by its identifier and saving an entity to the underlying data store.


Method Summary
 void delete(T entity)
          Delete the specified object from the persistent store.
 void deleteById(ID id)
          Delete an object from the persistent store based on the id.
 void deleteByIds(ID... ids)
          Delete objects from the persistent store based on the passed in id values.
 Iterable<T> findAll()
          Find all objects of type T.
 T findById(ID id)
          Find an object T with the specified id.
 Iterable<T> findByIds(ID... ids)
          Find objects of type T with the specified ids.
 void flush()
          If the implementation supports lazy writes, manually flush changes to the external database
 ReferenceSet<T> referenceByIds(ID... ids)
          Build a ReferenceSet to persisted objects with the passed in id values.
 void save(T entity)
          Call save to insert a new object into the persistent store or update a preexisting object that has been modified.
 void updateReferences(ReferenceSet<T> referenceSet, T updateObject)
          Update the objects referenced by the referenceSet with the changes in the updateObject.
 

Method Detail

findById

T findById(ID id)
           throws NoSuchItemException,
                  JeppettoException
Find an object T with the specified id.

Parameters:
id - of the desired object.
Returns:
Object with the specified id
Throws:
NoSuchItemException - if the object identified by the id is not found
JeppettoException - if any other failure occurs

findByIds

Iterable<T> findByIds(ID... ids)
                      throws JeppettoException
Find objects of type T with the specified ids.

Parameters:
ids - of the desired object.
Returns:
Iterable of T
Throws:
JeppettoException - if any other failure occurs

findAll

Iterable<T> findAll()
                    throws JeppettoException
Find all objects of type T.

Returns:
Iterable of T
Throws:
JeppettoException - if any underlying failure occurs

save

void save(T entity)
          throws OptimisticLockException,
                 JeppettoException
Call save to insert a new object into the persistent store or update a preexisting object that has been modified.

Parameters:
entity - to save.
Throws:
OptimisticLockException - if optimistic locking is enabled and a save is attempted on an already modified object.
JeppettoException - if any other failure occurs

delete

void delete(T entity)
            throws JeppettoException
Delete the specified object from the persistent store.

Parameters:
entity - to delete.
Throws:
JeppettoException - if any underlying failure occurs

deleteById

void deleteById(ID id)
                throws JeppettoException
Delete an object from the persistent store based on the id.

Parameters:
id - of the object to delete.
Throws:
JeppettoException - if any underlying failure occurs

deleteByIds

void deleteByIds(ID... ids)
                 throws JeppettoException
Delete objects from the persistent store based on the passed in id values.

Parameters:
ids - of the objects to delete.
Throws:
JeppettoException - if any underlying failure occurs

referenceByIds

ReferenceSet<T> referenceByIds(ID... ids)
Build a ReferenceSet to persisted objects with the passed in id values.

Parameters:
ids - of the objects to reference.
Throws:
JeppettoException - if any underlying failure occurs

updateReferences

void updateReferences(ReferenceSet<T> referenceSet,
                      T updateObject)
                      throws JeppettoException
Update the objects referenced by the referenceSet with the changes in the updateObject.

Parameters:
referenceSet - containing references to stored items
updateObject - the changes to make on references objects
Throws:
JeppettoException - if any underlying failure occurs

flush

void flush()
           throws JeppettoException
If the implementation supports lazy writes, manually flush changes to the external database

Throws:
JeppettoException - if any underlying failure occurs


Copyright © 2012. All Rights Reserved.