public class DAODispatcher extends BaseDAODispatcher implements GeneralDAO
This is an implementation of GeneralDAO that delegates to other DAOs depending on what entity class is being processed.
Set the specificDAOs Map in order to configure which DAO will be used for which entity class. If the map contains no entry for a given class, the generalDAO is used.
For example to dispatch operation on com.myproject.model.Customer to a DAO called customerDAO, set the map like this. (Of course tools like Spring can be used to do this configuration more elequently.)
MapspecificDAOs = new HashMap (); specificDAOs.put("com.myproject.model.Customer", customerDAO); DAODispatcher dispatcher = new DAODispatcher(); dispatcher.setSpecificDAOs(specificDAOs);
Modifier and Type | Field and Description |
---|---|
protected GeneralDAO |
generalDAO |
specificDAOs
Constructor and Description |
---|
DAODispatcher() |
Modifier and Type | Method and Description |
---|---|
int |
count(ISearch search)
Returns the total number of results that would be returned using the
given
ISearch if there were no paging or maxResult limits. |
void |
create(java.lang.Object object)
Add the specified object as a new entry in the datastore.
|
boolean |
createOrUpdate(java.lang.Object object)
If the id of the object is null or zero, create, otherwise update.
|
boolean |
deleteById(java.lang.Class<?> klass,
java.io.Serializable id)
Remove the object with the specified id and class from the datastore.
|
boolean |
deleteEntity(java.lang.Object object)
Remove the specified object from the datastore.
|
<T> T |
fetch(java.lang.Class<T> klass,
java.io.Serializable id)
Get the object with the specified id and class from the datastore.
|
<T> java.util.List<T> |
fetchAll(java.lang.Class<T> klass)
Get a list of all the objects of the specified type.
|
void |
flush()
Deprecated.
use flush(Class>)
|
void |
flush(java.lang.Class<?> klass) |
Filter |
getFilterFromExample(java.lang.Object example)
Generates a search filter from the given example using default options.
|
Filter |
getFilterFromExample(java.lang.Object example,
ExampleOptions options)
Generates a search filter from the given example using the specified options.
|
boolean |
isConnected(java.lang.Object object)
Returns true if the object is connected to the current Hibernate session.
|
void |
refresh(java.lang.Object object)
Refresh the content of the given entity from the current datastore state.
|
java.util.List |
search(ISearch search)
Search for objects given the search parameters in the specified
ISearch object. |
SearchResult |
searchAndCount(ISearch search)
Returns a
SearchResult object that includes the list of
results like search() and the total length like
searchLength . |
java.lang.Object |
searchUnique(ISearch search)
ISearch for a single result using the given parameters.
|
void |
setGeneralDAO(GeneralDAO generalDAO)
GeneralDAO has default implementations for the standard DAO methods.
|
void |
update(java.lang.Object object)
Update the corresponding object in the datastore with the properties of
the specified object.
|
callMethod, callMethod, getSpecificDAO, getTypeFromArray, getUniformArrayType, setSpecificDAOs
protected GeneralDAO generalDAO
public void setGeneralDAO(GeneralDAO generalDAO)
public void create(java.lang.Object object)
GeneralDAO
create
in interface GeneralDAO
public boolean createOrUpdate(java.lang.Object object)
GeneralDAO
createOrUpdate
in interface GeneralDAO
true
if create; false
if update.public boolean deleteById(java.lang.Class<?> klass, java.io.Serializable id)
GeneralDAO
deleteById
in interface GeneralDAO
true
if the object is found in the datastore and
removed, false
if the item is not found.public boolean deleteEntity(java.lang.Object object)
GeneralDAO
deleteEntity
in interface GeneralDAO
true
if the object is found in the datastore and
removed, false
if the item is not found.public <T> T fetch(java.lang.Class<T> klass, java.io.Serializable id)
GeneralDAO
fetch
in interface GeneralDAO
public <T> java.util.List<T> fetchAll(java.lang.Class<T> klass)
GeneralDAO
fetchAll
in interface GeneralDAO
public void flush()
GeneralDAO
flush
in interface GeneralDAO
public void flush(java.lang.Class<?> klass)
public boolean isConnected(java.lang.Object object)
GeneralDAO
isConnected
in interface GeneralDAO
public void refresh(java.lang.Object object)
GeneralDAO
refresh
in interface GeneralDAO
public java.util.List search(ISearch search)
GeneralDAO
ISearch
object.search
in interface GeneralDAO
public SearchResult searchAndCount(ISearch search)
GeneralDAO
SearchResult
object that includes the list of
results like search()
and the total length like
searchLength
.searchAndCount
in interface GeneralDAO
public int count(ISearch search)
GeneralDAO
ISearch
if there were no paging or maxResult limits.count
in interface GeneralDAO
public java.lang.Object searchUnique(ISearch search) throws org.hibernate.NonUniqueResultException
GeneralDAO
searchUnique
in interface GeneralDAO
org.hibernate.NonUniqueResultException
public void update(java.lang.Object object)
GeneralDAO
update
in interface GeneralDAO
public Filter getFilterFromExample(java.lang.Object example)
GeneralDAO
getFilterFromExample
in interface GeneralDAO
public Filter getFilterFromExample(java.lang.Object example, ExampleOptions options)
GeneralDAO
getFilterFromExample
in interface GeneralDAO