E
- the class which this DAO managespublic class AbstractDAO<E> extends Object
Constructor and Description |
---|
AbstractDAO(org.hibernate.SessionFactory sessionFactory)
Creates a new DAO with a given session provider.
|
Modifier and Type | Method and Description |
---|---|
protected org.hibernate.Criteria |
criteria()
Deprecated.
Use
criteriaQuery() instead. |
protected javax.persistence.criteria.CriteriaQuery<E> |
criteriaQuery()
Creates a new
CriteriaQuery for <E> . |
protected org.hibernate.Session |
currentSession()
Returns the current
Session . |
protected E |
get(Serializable id)
Return the persistent instance of
<E> with the given identifier, or null if
there is no such persistent instance. |
Class<E> |
getEntityClass()
Returns the entity class managed by this DAO.
|
protected <T> T |
initialize(T proxy)
Force initialization of a proxy or persistent collection.
|
protected List<E> |
list(org.hibernate.Criteria criteria)
Get the results of a
Criteria query. |
protected List<E> |
list(javax.persistence.criteria.CriteriaQuery<E> criteria)
Get the results of a
CriteriaQuery query. |
protected List<E> |
list(org.hibernate.query.Query<E> query)
Get the results of a query.
|
protected org.hibernate.query.Query<?> |
namedQuery(String queryName)
Returns a named
Query . |
protected E |
persist(E entity)
Either save or update the given instance, depending upon resolution of the unsaved-value
checks (see the manual for discussion of unsaved-value checking).
|
protected org.hibernate.query.Query<E> |
query(String queryString)
Returns a typed
Query |
protected E |
uniqueResult(org.hibernate.Criteria criteria)
Convenience method to return a single instance that matches the criteria, or null if the
criteria returns no results.
|
protected E |
uniqueResult(javax.persistence.criteria.CriteriaQuery<E> criteriaQuery)
Convenience method to return a single instance that matches the criteria query,
or null if the criteria returns no results.
|
protected E |
uniqueResult(org.hibernate.query.Query<E> query)
Convenience method to return a single instance that matches the query, or null if the query
returns no results.
|
public AbstractDAO(org.hibernate.SessionFactory sessionFactory)
sessionFactory
- a session providerprotected org.hibernate.Session currentSession()
Session
.@Deprecated protected org.hibernate.Criteria criteria()
criteriaQuery()
instead.Criteria
query for <E>
.Criteria
querySharedSessionContract.createCriteria(Class)
protected javax.persistence.criteria.CriteriaQuery<E> criteriaQuery()
CriteriaQuery
for <E>
.CriteriaQuery
queryprotected org.hibernate.query.Query<?> namedQuery(String queryName) throws org.hibernate.HibernateException
Query
.queryName
- the name of the queryorg.hibernate.HibernateException
SharedSessionContract.getNamedQuery(String)
protected org.hibernate.query.Query<E> query(String queryString)
Query
queryString
- HQL querypublic Class<E> getEntityClass()
protected E uniqueResult(javax.persistence.criteria.CriteriaQuery<E> criteriaQuery) throws org.hibernate.HibernateException
criteriaQuery
- the CriteriaQuery
query to runnull
org.hibernate.HibernateException
- if there is more than one matching resultprotected E uniqueResult(org.hibernate.Criteria criteria) throws org.hibernate.HibernateException
criteria
- the Criteria
query to runnull
org.hibernate.HibernateException
- if there is more than one matching resultCriteria.uniqueResult()
protected E uniqueResult(org.hibernate.query.Query<E> query) throws org.hibernate.HibernateException
query
- the query to runnull
org.hibernate.HibernateException
- if there is more than one matching resultQuery.uniqueResult()
protected List<E> list(org.hibernate.Criteria criteria) throws org.hibernate.HibernateException
Criteria
query.criteria
- the Criteria
query to runorg.hibernate.HibernateException
Criteria.list()
protected List<E> list(javax.persistence.criteria.CriteriaQuery<E> criteria) throws org.hibernate.HibernateException
CriteriaQuery
query.criteria
- the CriteriaQuery
query to runorg.hibernate.HibernateException
protected List<E> list(org.hibernate.query.Query<E> query) throws org.hibernate.HibernateException
query
- the query to runorg.hibernate.HibernateException
Query.list()
protected E get(Serializable id)
<E>
with the given identifier, or null
if
there is no such persistent instance. (If the instance, or a proxy for the instance, is
already associated with the session, return that instance or proxy.)id
- an identifiernull
org.hibernate.HibernateException
Session.get(Class, Serializable)
protected E persist(E entity) throws org.hibernate.HibernateException
entity
- a transient or detached instance containing new or updated stateorg.hibernate.HibernateException
Session.saveOrUpdate(Object)
protected <T> T initialize(T proxy) throws org.hibernate.HibernateException
proxy
- a persistable object, proxy, persistent collection or null
org.hibernate.HibernateException
- if we can't initialize the proxy at this time, eg. the Session
was closedCopyright © 2021. All rights reserved.