dk.netarkivet.wayback.indexer
Class GenericHibernateDAO<T,PK extends java.io.Serializable>

java.lang.Object
  extended by dk.netarkivet.wayback.indexer.GenericHibernateDAO<T,PK>
Type Parameters:
T - The type of the persistent entity.
PK - The type of the primary key for the entity.
All Implemented Interfaces:
GenericDAO<T,PK>
Direct Known Subclasses:
ArchiveFileDAO

public class GenericHibernateDAO<T,PK extends java.io.Serializable>
extends java.lang.Object
implements GenericDAO<T,PK>

An implementation of Generic DAO which is specialised for hibernate object stores.


Constructor Summary
GenericHibernateDAO(java.lang.Class<T> type)
          Constructor for the class.
 
Method Summary
 PK create(T o)
          Persist the newInstance object into database.
 void delete(T o)
          Remove an object from persistent storage in the database.
protected  java.util.List<T> findByCriteria(org.hibernate.criterion.Criterion... criterion)
          Use this inside subclasses as a convenience method to find objects matching a given criterion.
protected  org.hibernate.Session getSession()
          Return a session object for managing instances of this class.
 T read(PK id)
          Retrieve an object that was previously persisted to the database using the indicated id as primary key.
 void update(T o)
          Save changes made to a persistent object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericHibernateDAO

public GenericHibernateDAO(java.lang.Class<T> type)
Constructor for the class.

Parameters:
type - the type of the persistent entity managed by this class.
Method Detail

create

public PK create(T o)
Description copied from interface: GenericDAO
Persist the newInstance object into database.

Specified by:
create in interface GenericDAO<T,PK extends java.io.Serializable>
Parameters:
o - the object to persist.
Returns:
the key assigned to the object.

read

public T read(PK id)
Description copied from interface: GenericDAO
Retrieve an object that was previously persisted to the database using the indicated id as primary key.

Specified by:
read in interface GenericDAO<T,PK extends java.io.Serializable>
Parameters:
id - the key of the object to be retrieved.
Returns:
the retrieved object.

update

public void update(T o)
Description copied from interface: GenericDAO
Save changes made to a persistent object.

Specified by:
update in interface GenericDAO<T,PK extends java.io.Serializable>
Parameters:
o - the object to be updated.

delete

public void delete(T o)
Description copied from interface: GenericDAO
Remove an object from persistent storage in the database.

Specified by:
delete in interface GenericDAO<T,PK extends java.io.Serializable>
Parameters:
o - the object to be deleted.

getSession

protected org.hibernate.Session getSession()
Return a session object for managing instances of this class.

Returns:
the session.

findByCriteria

protected java.util.List<T> findByCriteria(org.hibernate.criterion.Criterion... criterion)
Use this inside subclasses as a convenience method to find objects matching a given criterion.

Parameters:
criterion - the criteria to be matched.
Returns:
a list of objects matching the criterion.