T
- The type of the domain object for which this instance is to be
used.ID
- The type of the id of the domain object for which this instance is
to be used.public class GenericDAOImpl<T,ID extends java.io.Serializable> extends HibernateBaseDAO implements GenericDAO<T,ID>
GenericDAO
using Hibernate.
The SessionFactory property is annotated for automatic resource injection.Modifier and Type | Field and Description |
---|---|
protected java.lang.Class<T> |
persistentClass |
Constructor and Description |
---|
GenericDAOImpl() |
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(T object)
Add the specified object as a new entry in the datastore.
|
boolean |
createOrUpdate(T object)
If the id of the object is null or zero, create, otherwise update.
|
boolean |
deleteById(ID id)
Remove the object of this type with the specified id from the datastore.
|
boolean |
deleteEntity(T object)
Remove the specified object from the datastore.
|
T |
fetch(ID id)
Get the object of this type with the specified id from the datastore.
|
java.util.List<T> |
fetchAll()
Get a list of all the objects of this type.
|
void |
flush()
Flushes changes in the Hibernate cache to the datastore.
|
Filter |
getFilterFromExample(T example)
Generates a search filter from the given example using default options.
|
Filter |
getFilterFromExample(T 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<T> |
search(ISearch search)
Search for objects of this type given the search parameters in the
specified
ISearch object. |
SearchResult<T> |
searchAndCount(ISearch search)
Returns a
SearchResult object that includes the list of
results like search() and the total length like
searchLength . |
java.util.List |
searchGeneric(ISearch search)
Search for objects given the search parameters in the specified
ISearch object. |
java.lang.Object |
searchUnique(ISearch search)
Search for a single result using the given parameters.
|
void |
update(T object)
Update the corresponding object in the datastore with the properties of
the specified object.
|
_all, _count, _count, _count, _deleteById, _deleteById, _deleteEntities, _deleteEntity, _exists, _exists, _exists, _flush, _get, _get, _getFilterFromExample, _getFilterFromExample, _load, _load, _load, _merge, _persist, _refresh, _save, _save, _saveOrUpdate, _saveOrUpdateIsNew, _saveOrUpdateIsNew, _search, _search, _searchAndCount, _searchAndCount, _searchUnique, _searchUnique, _sessionContains, _update, getMetadataUtil, getSearchProcessor, getSession, getSessionFactory, setSessionFactory
protected java.lang.Class<T> persistentClass
public void create(T object)
GenericDAO
create
in interface GenericDAO<T,ID extends java.io.Serializable>
public boolean createOrUpdate(T object)
GenericDAO
createOrUpdate
in interface GenericDAO<T,ID extends java.io.Serializable>
true
if create; false
if update.public boolean deleteById(ID id)
GenericDAO
deleteById
in interface GenericDAO<T,ID extends java.io.Serializable>
true
if the object is found in the datastore and
removed, false
if the item is not found.public boolean deleteEntity(T object)
GenericDAO
deleteEntity
in interface GenericDAO<T,ID extends java.io.Serializable>
true
if the object is found in the datastore and
removed, false
if the item is not found.public T fetch(ID id)
GenericDAO
fetch
in interface GenericDAO<T,ID extends java.io.Serializable>
public java.util.List<T> fetchAll()
GenericDAO
fetchAll
in interface GenericDAO<T,ID extends java.io.Serializable>
public void update(T object)
GenericDAO
update
in interface GenericDAO<T,ID extends java.io.Serializable>
public java.util.List<T> search(ISearch search)
GenericDAO
ISearch
object.search
in interface GenericDAO<T,ID extends java.io.Serializable>
public int count(ISearch search)
GenericDAO
ISearch
if there were no paging or maxResult limits.count
in interface GenericDAO<T,ID extends java.io.Serializable>
public SearchResult<T> searchAndCount(ISearch search)
GenericDAO
SearchResult
object that includes the list of
results like search()
and the total length like
searchLength
.searchAndCount
in interface GenericDAO<T,ID extends java.io.Serializable>
public boolean isConnected(java.lang.Object object)
GenericDAO
isConnected
in interface GenericDAO<T,ID extends java.io.Serializable>
public void flush()
GenericDAO
flush
in interface GenericDAO<T,ID extends java.io.Serializable>
public void refresh(java.lang.Object object)
GenericDAO
refresh
in interface GenericDAO<T,ID extends java.io.Serializable>
public java.util.List searchGeneric(ISearch search)
GenericDAO
ISearch
object. Return an untyped result list. The result
type can be determined by fetch mode and fetches on the search.searchGeneric
in interface GenericDAO<T,ID extends java.io.Serializable>
public java.lang.Object searchUnique(ISearch search) throws org.hibernate.NonUniqueResultException
GenericDAO
searchUnique
in interface GenericDAO<T,ID extends java.io.Serializable>
org.hibernate.NonUniqueResultException
public Filter getFilterFromExample(T example)
GenericDAO
getFilterFromExample
in interface GenericDAO<T,ID extends java.io.Serializable>
public Filter getFilterFromExample(T example, ExampleOptions options)
GenericDAO
getFilterFromExample
in interface GenericDAO<T,ID extends java.io.Serializable>