T - the generic type of the dao object.PK - the generic type of the primary key from the dao object.public class GenericHibernateDao<T extends BaseEntity<PK>,PK extends Serializable> extends Object implements SessionFactoryDao<T,PK>
| Constructor and Description |
|---|
GenericHibernateDao() |
| Modifier and Type | Method and Description |
|---|---|
void |
delete(List<T> objects)
Delete all persistent objects in the given list.
|
void |
delete(PK id)
Deletes an object of a given Id.
|
void |
delete(PK id,
org.hibernate.Session session)
Deletes an object of a given Id with the given session object.
|
void |
delete(T object)
Deletes the given object from persistent storage in the database.
|
void |
delete(T object,
org.hibernate.Session session)
Deletes the given object from persistent storage in the database with the given session
object.
|
void |
evict(T object)
Remove this instance from the session cache.
|
boolean |
exists(PK id)
Checks if an entry exists with the given id.
|
List<T> |
find(String hqlQuery,
String[] params,
Object[] paramValues,
org.hibernate.type.Type[] paramTypes,
Integer start,
Integer count)
Returns a list from the result from the given hqlquery.
|
List<T> |
findAll()
Returns a list of all persistent objects.
|
List<T> |
findByCriteria(org.hibernate.criterion.Criterion... criterion)
Hibernate wrapper.
|
List<T> |
findByExample(T exampleInstance,
String... excludeProperty)
Find by example.
|
T |
get(PK id)
Retrieve a persisted object with a given id from the database.
|
T |
get(PK id,
org.hibernate.Session session)
Loads the given Object with the given session object.
|
DataSource |
getDataSource()
Gets the data source.
|
org.springframework.jdbc.core.JdbcTemplate |
getJdbcTemplate()
Gets the jdbc template.
|
Class<T> |
getPersistentClass()
Gets the persitent class.
|
org.hibernate.Query |
getQuery(String hqlQuery)
Gets a query object from the given String.
|
org.hibernate.Query |
getQuery(String queryString,
org.hibernate.Session session)
Gets a query object from the given String with the given session object.
|
org.hibernate.Session |
getSession()
Gets the hibernate session.
|
org.hibernate.SessionFactory |
getSessionFactory()
Gets the session factory.
|
Class<T> |
getType()
Gets the class type.
|
T |
load(PK id)
Retrieve a persisted object with a given id from the database.
|
T |
load(PK id,
org.hibernate.Session session)
Retrieve a persisted object with a given id from the database with the given session object.
|
List<T> |
merge(List<T> objects)
Merges all new objects in the given list.
|
T |
merge(T object)
Merges the given object.
|
void |
refresh(T object)
Re-read the state of the given instance from the underlying database.
|
List<PK> |
save(List<T> objects)
Save all new objects in the given list.
|
PK |
save(T object)
Persist the given object into database.
|
PK |
save(T object,
org.hibernate.Session session)
Save the given object.
|
void |
saveOrUpdate(List<T> objects)
Save or update all transient objects in the given list.
|
void |
saveOrUpdate(T object)
Save or update the given persistent object.
|
void |
saveOrUpdate(T object,
org.hibernate.Session session)
Save or update the given transient object.
|
void |
setDataSource(DataSource dataSource)
Sets the data source.
|
void |
setJdbcTemplate(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate)
Sets the jdbc template.
|
void |
setSession(org.hibernate.Session session)
Sets the hibernate session.
|
void |
setSessionFactory(org.hibernate.SessionFactory sessionFactory)
Sets the session factory.
|
void |
update(List<T> objects)
Update all transient objects in the given list.
|
void |
update(T object)
Update changes made to the given object.
|
void |
update(T object,
org.hibernate.Session session)
Updates the given object with the given session object.
|
public void delete(List<T> objects)
delete in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>objects - the list with the persistent objects to deletepublic void delete(PK id)
delete in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>id - the idpublic void delete(PK id, org.hibernate.Session session)
delete in interface SessionFactoryDao<T extends BaseEntity<PK>,PK extends Serializable>id - the idsession - the session to use for the operation.public void delete(T object)
delete in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>object - the persistent objectpublic void delete(T object, org.hibernate.Session session)
delete in interface SessionFactoryDao<T extends BaseEntity<PK>,PK extends Serializable>object - the persistent objectsession - the session to use for the operation.public void evict(T object)
evict in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>object - the object to evict.public boolean exists(PK id)
exists in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>id - the id to checkpublic List<T> find(String hqlQuery, String[] params, Object[] paramValues, org.hibernate.type.Type[] paramTypes, Integer start, Integer count)
find in interface SessionFactoryDao<T extends BaseEntity<PK>,PK extends Serializable>hqlQuery - the hql query.params - Array from the parameter for the query.paramValues - Array from the values from the parameters for the query.paramTypes - Array which defines what kind of type the the parameter is.start - Defines from where to start the result.count - Defines how much rows to get from the query.public List<T> findAll()
findAll in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>public List<T> findByCriteria(org.hibernate.criterion.Criterion... criterion)
findByCriteria in interface SessionFactoryDao<T extends BaseEntity<PK>,PK extends Serializable>criterion - the criterionpublic List<T> findByExample(T exampleInstance, String... excludeProperty)
findByExample in interface SessionFactoryDao<T extends BaseEntity<PK>,PK extends Serializable>exampleInstance - the example instanceexcludeProperty - the exclude propertypublic T get(PK id)
get in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>id - the idpublic T get(PK id, org.hibernate.Session session)
get in interface SessionFactoryDao<T extends BaseEntity<PK>,PK extends Serializable>id - Id to loadsession - the session to use for the operation.public DataSource getDataSource()
public org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate()
public Class<T> getPersistentClass()
public org.hibernate.Query getQuery(String hqlQuery)
getQuery in interface SessionFactoryDao<T extends BaseEntity<PK>,PK extends Serializable>hqlQuery - the hql query as Stringpublic org.hibernate.Query getQuery(String queryString, org.hibernate.Session session)
getQuery in interface SessionFactoryDao<T extends BaseEntity<PK>,PK extends Serializable>queryString - the hql query as Stringsession - the session to use for the operation.public org.hibernate.Session getSession()
getSession in interface SessionFactoryDao<T extends BaseEntity<PK>,PK extends Serializable>public org.hibernate.SessionFactory getSessionFactory()
public Class<T> getType()
getType in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>public T load(PK id)
load in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>id - the idpublic T load(PK id, org.hibernate.Session session)
load in interface SessionFactoryDao<T extends BaseEntity<PK>,PK extends Serializable>id - the idsession - the session to use for the operation.public List<T> merge(List<T> objects)
GenericDaomerge in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>objects - the list to savepublic T merge(T object)
merge in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>object - the objectpublic void refresh(T object)
refresh in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>object - the object to re-read.public List<PK> save(List<T> objects)
save in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>objects - the list to savepublic PK save(T object)
save in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>object - the new instance to save.public PK save(T object, org.hibernate.Session session)
save in interface SessionFactoryDao<T extends BaseEntity<PK>,PK extends Serializable>object - the new instance to save.session - the session to use for the operation.public void saveOrUpdate(List<T> objects)
saveOrUpdate in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>objects - the transient objectspublic void saveOrUpdate(T object)
saveOrUpdate in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>object - the transient object to save or update.public void saveOrUpdate(T object, org.hibernate.Session session)
saveOrUpdate in interface SessionFactoryDao<T extends BaseEntity<PK>,PK extends Serializable>object - the transient object to save or update.session - the session to use for the operation.public void setDataSource(DataSource dataSource)
dataSource - the new data sourcepublic void setJdbcTemplate(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate)
jdbcTemplate - the new jdbc templatepublic void setSession(org.hibernate.Session session)
setSession in interface SessionFactoryDao<T extends BaseEntity<PK>,PK extends Serializable>session - The hibernate session to set.public void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
sessionFactory - the new session factorypublic void update(List<T> objects)
update in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>objects - the transient objects to update.public void update(T object)
update in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>object - the transient object to update.public void update(T object, org.hibernate.Session session)
update in interface SessionFactoryDao<T extends BaseEntity<PK>,PK extends Serializable>object - the transient object to save or update.session - the session to use for the operation.Copyright © 2015–2017 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.