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(Object object)
Add the specified object as a new entry in the datastore.
|
boolean |
createOrUpdate(Object object)
If the id of the object is null or zero, create, otherwise update.
|
boolean |
deleteById(Class<?> klass,
Serializable id)
Remove the object with the specified id and class from the datastore.
|
boolean |
deleteEntity(Object object)
Remove the specified object from the datastore.
|
<T> T |
fetch(Class<T> klass,
Serializable id)
Get the object with the specified id and class from the datastore.
|
<T> List<T> |
fetchAll(Class<T> klass)
Get a list of all the objects of the specified type.
|
void |
flush()
Deprecated.
use flush(Class>)
|
void |
flush(Class<?> klass) |
Filter |
getFilterFromExample(Object example)
Generates a search filter from the given example using default options.
|
Filter |
getFilterFromExample(Object example,
ExampleOptions options)
Generates a search filter from the given example using the specified options.
|
boolean |
isConnected(Object object)
Returns true if the object is connected to the current Hibernate session.
|
void |
refresh(Object object)
Refresh the content of the given entity from the current datastore state.
|
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. |
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(Object object)
Update the corresponding object in the datastore with the properties of
the specified object.
|
callMethod, callMethod, getSpecificDAO, getTypeFromArray, getUniformArrayType, setSpecificDAOsprotected GeneralDAO generalDAO
public void setGeneralDAO(GeneralDAO generalDAO)
public void create(Object object)
GeneralDAOcreate in interface GeneralDAOpublic boolean createOrUpdate(Object object)
GeneralDAOcreateOrUpdate in interface GeneralDAOtrue if create; false if update.public boolean deleteById(Class<?> klass, Serializable id)
GeneralDAOdeleteById in interface GeneralDAOtrue if the object is found in the datastore and
removed, false if the item is not found.public boolean deleteEntity(Object object)
GeneralDAOdeleteEntity in interface GeneralDAOtrue if the object is found in the datastore and
removed, false if the item is not found.public <T> T fetch(Class<T> klass, Serializable id)
GeneralDAOfetch in interface GeneralDAOpublic <T> List<T> fetchAll(Class<T> klass)
GeneralDAOfetchAll in interface GeneralDAOpublic void flush()
GeneralDAOflush in interface GeneralDAOpublic void flush(Class<?> klass)
public boolean isConnected(Object object)
GeneralDAOisConnected in interface GeneralDAOpublic void refresh(Object object)
GeneralDAOrefresh in interface GeneralDAOpublic List search(ISearch search)
GeneralDAOISearch object.search in interface GeneralDAOpublic SearchResult searchAndCount(ISearch search)
GeneralDAOSearchResult object that includes the list of
results like search() and the total length like
searchLength.searchAndCount in interface GeneralDAOpublic int count(ISearch search)
GeneralDAOISearch if there were no paging or maxResult limits.count in interface GeneralDAOpublic Object searchUnique(ISearch search) throws org.hibernate.NonUniqueResultException
GeneralDAOsearchUnique in interface GeneralDAOorg.hibernate.NonUniqueResultExceptionpublic void update(Object object)
GeneralDAOupdate in interface GeneralDAOpublic Filter getFilterFromExample(Object example)
GeneralDAOgetFilterFromExample in interface GeneralDAOpublic Filter getFilterFromExample(Object example, ExampleOptions options)
GeneralDAOgetFilterFromExample in interface GeneralDAOCopyright © 2008-2013. All Rights Reserved.