T - the generic type of the dao entity.PK - the generic type of the primary key from the dao entity.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> entities)
Delete all persistent entities in the given list.
|
void |
delete(PK id)
Deletes an entity of a given Id.
|
void |
delete(PK id,
org.hibernate.Session session)
Deletes an entity of a given Id with the given session entity.
|
void |
delete(T entity)
Deletes the given entity from persistent storage in the database.
|
void |
delete(T entity,
org.hibernate.Session session)
Deletes the given entity from persistent storage in the database with the given session
entity.
|
void |
evict(T entity)
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 entities.
|
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 entity with a given id from the database.
|
T |
get(PK id,
org.hibernate.Session session)
Loads the given Object with the given session entity.
|
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 entity from the given String.
|
org.hibernate.Query |
getQuery(String queryString,
org.hibernate.Session session)
Gets a query entity from the given String with the given session entity.
|
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 entity with a given id from the database.
|
T |
load(PK id,
org.hibernate.Session session)
Retrieve a persisted entity with a given id from the database with the given session entity.
|
List<T> |
merge(List<T> entities)
Merges all new entities in the given list.
|
T |
merge(T entity)
Merges the given entity.
|
void |
refresh(T entity)
Re-read the state of the given instance from the underlying database.
|
List<PK> |
save(List<T> entities)
Save all new entities in the given list.
|
PK |
save(T entity)
Persist the given entity into database.
|
PK |
save(T entity,
org.hibernate.Session session)
Save the given entity.
|
void |
saveOrUpdate(List<T> entities)
Save or update all transient entities in the given list.
|
void |
saveOrUpdate(T entity)
Save or update the given persistent entity.
|
void |
saveOrUpdate(T entity,
org.hibernate.Session session)
Save or update the given transient entity.
|
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> entities)
Update all transient entities in the given list.
|
void |
update(T entity)
Update changes made to the given entity.
|
void |
update(T entity,
org.hibernate.Session session)
Updates the given entity with the given session entity.
|
public void delete(List<T> entities)
delete in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>entities - the list with the persistent entities 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 entity)
delete in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>entity - the persistent entitypublic void delete(T entity, org.hibernate.Session session)
delete in interface SessionFactoryDao<T extends BaseEntity<PK>,PK extends Serializable>entity - the persistent entitysession - the session to use for the operation.public void evict(T entity)
evict in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>entity - the entity 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> entities)
GenericDaomerge in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>entities - the list to savepublic T merge(T entity)
merge in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>entity - the entitypublic void refresh(T entity)
refresh in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>entity - the entity to re-read.public List<PK> save(List<T> entities)
save in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>entities - the list to savepublic PK save(T entity)
save in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>entity - the new instance to save.public PK save(T entity, org.hibernate.Session session)
save in interface SessionFactoryDao<T extends BaseEntity<PK>,PK extends Serializable>entity - the new instance to save.session - the session to use for the operation.public void saveOrUpdate(List<T> entities)
saveOrUpdate in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>entities - the transient entitiespublic void saveOrUpdate(T entity)
saveOrUpdate in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>entity - the transient entity to save or update.public void saveOrUpdate(T entity, org.hibernate.Session session)
saveOrUpdate in interface SessionFactoryDao<T extends BaseEntity<PK>,PK extends Serializable>entity - the transient entity 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> entities)
update in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>entities - the transient entities to update.public void update(T entity)
update in interface GenericDao<T extends BaseEntity<PK>,PK extends Serializable>entity - the transient entity to update.public void update(T entity, org.hibernate.Session session)
update in interface SessionFactoryDao<T extends BaseEntity<PK>,PK extends Serializable>entity - the transient entity to save or update.session - the session to use for the operation.Copyright © 2015–2017 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.