org.clazzes.util.aop.generic
Interface GenericDAO<T>

All Known Subinterfaces:
GenericGetAllDAO<T>, GenericJoinDAO<T,B>

public interface GenericDAO<T>

This interface is implemented by DAOs, which support the traditional save, update and delete operations on a single data class.


Method Summary
 void delete(Serializable id)
          Deletes the given object of the generic's type from the database.
 T get(Serializable id)
          Returns the database object of the generic's type with the given database Id.
 Class<T> getPersistentClass()
           
 T insert(T t)
          Saves the given object of the generic's type to the database.
 T merge(T t)
          Merges (updates) the given object of the generic's type in the database.
 T refresh(T t)
          Refreshes (reloads, reverts) the given object of the generic's type from the database.
 T update(T t)
          Updates the given object of the generic's type in the database.
 

Method Detail

getPersistentClass

Class<T> getPersistentClass()
Returns:
The class object for the persistent class T.

get

T get(Serializable id)
Returns the database object of the generic's type with the given database Id.

Parameters:
id - The database Id of the object to be retrieved.
Returns:
The found object of type T.

insert

T insert(T t)
Saves the given object of the generic's type to the database. If the object has no database Id yet, a new instance of the object will be returned, which carries a newly generated database Id.

Parameters:
t - The object to be save to the database.
Returns:
A copy of the created object of type T possibly with a freshly generated database Id.

update

T update(T t)
Updates the given object of the generic's type in the database.

Parameters:
t - The object to be updated in the database.
Returns:
A copy of the object t.

merge

T merge(T t)
Merges (updates) the given object of the generic's type in the database.

Parameters:
t - The object to be updated in the database.
Returns:
A copy of the object t.

refresh

T refresh(T t)
Refreshes (reloads, reverts) the given object of the generic's type from the database.

Parameters:
t - The object to be reloaded from the database.
Returns:
A copy of the object t.

delete

void delete(Serializable id)
Deletes the given object of the generic's type from the database.

Parameters:
id - Database-Id of object to be deleted from the database.


Copyright © 2012. All Rights Reserved.