org.dellroad.stuff.dao
Interface DAO<T>

All Known Implementing Classes:
AbstractDAO

public interface DAO<T>

Data Access Object (DAO) generic interface.


Method Summary
 void clear()
          Clear the session cache.
 void delete(T obj)
          Delete the given instance from the persistent store.
 void detach(T obj)
          Evict an object from the session cache.
 void flush()
          Flush outstanding changes to the persistent store.
 List<T> getAll()
          Get all instances.
 T getById(long id)
          Get an instance by ID.
 T getReference(long id)
          Get a reference to an instance by ID.
 boolean isReadOnly()
          Determine if the current transaction is read-only.
 T merge(T obj)
          Merge the given object into the current session.
 void refresh(T obj)
          Refresh the given object from the database.
 void save(T obj)
          Save a newly created instance.
 void setFlushMode(FlushModeType flushMode)
          Set flush mode.
 

Method Detail

getById

T getById(long id)
Get an instance by ID. This assumes object IDs are long values.


getAll

List<T> getAll()
Get all instances.


getReference

T getReference(long id)
Get a reference to an instance by ID. This assumes object IDs are long values.

Note if the instance does not exist, then an exception may be thrown either here or later upon first access.


save

void save(T obj)
Save a newly created instance.


delete

void delete(T obj)
Delete the given instance from the persistent store.


merge

T merge(T obj)
Merge the given object into the current session.


refresh

void refresh(T obj)
Refresh the given object from the database.


detach

void detach(T obj)
Evict an object from the session cache.


flush

void flush()
Flush outstanding changes to the persistent store.


setFlushMode

void setFlushMode(FlushModeType flushMode)
Set flush mode.


clear

void clear()
Clear the session cache.


isReadOnly

boolean isReadOnly()
Determine if the current transaction is read-only.

Returns:
true if the current transaction is read-only
Throws:
IllegalStateException - if no transaction is associated with the current thread