public abstract class HibernateDao extends StatelessDao
Modifier and Type | Field and Description |
---|---|
protected BatchFinder |
batchFinder |
protected SessionBatchProcessor |
batchProcessor |
protected org.slf4j.Logger |
logger |
protected StatelessSessionBatchProcessor |
statelessSessionBatchProcessor |
protected Clock |
timeSource |
sessionFactory
Constructor and Description |
---|
HibernateDao() |
Modifier and Type | Method and Description |
---|---|
protected org.hibernate.query.Query |
createHibernateQuery(HQLQuery hqlQuery)
|
abstract Class<?> |
getPersistentClass()
All subclasses of HibernateDao must implement this method for
#load(long) to work correctly. |
<T> T |
load(Class<T> persistentClass,
Serializable id)
Loads a persisted entity from the persistence store.
|
Object |
load(Serializable id)
Loads a persisted entity from the persistence store.
|
<T> T |
loadReference(Class<T> persistentClass,
long id)
This method calls the
session.load method to
obtain a proxy (or actual instance if the object is in session)
by NOT hitting the database immediately. |
Object |
loadReference(long id)
This method calls the
session.load method to
obtain a proxy (or actual instance if the object is in session)
by NOT hitting the database immediately. |
void |
remove(Object persistentObject)
Removes the DAO object from the persistence store.
|
void |
save(Object persistentObject)
Saves a new DAO object to the persistence store.
|
void |
saveOrUpdate(Object persistentObject)
Saves or updates DAO object to the persistence store.
|
protected org.hibernate.Session |
session() |
void |
setBatchFinder(BatchFinder batchFinder) |
void |
setBatchProcessor(SessionBatchProcessor batchProcessor) |
void |
setClock(Clock timeSource) |
void |
setStatelessSessionBatchProcessor(StatelessSessionBatchProcessor statelessSessionBatchProcessor) |
void |
update(Object persistentObject)
Updates an existing DAO object, if the object does not exist it will be added to the persistence store.
|
setSessionFactory, withStatelessSession
protected final org.slf4j.Logger logger
protected BatchFinder batchFinder
protected SessionBatchProcessor batchProcessor
protected StatelessSessionBatchProcessor statelessSessionBatchProcessor
protected Clock timeSource
public abstract Class<?> getPersistentClass()
#load(long)
to work correctly.public <T> T load(Class<T> persistentClass, Serializable id) throws ObjectNotFoundException
persistentClass
- The entity type to loadid
- The unique identifier of the object to load from the persistence store.ObjectNotFoundException
- when the requested entity is not found.public Object load(Serializable id) throws ObjectNotFoundException
id
- The unique identifier of the object to load from the persistence store.ObjectNotFoundException
- when the requested entity is not found.public <T> T loadReference(Class<T> persistentClass, long id)
session.load
method to
obtain a proxy (or actual instance if the object is in session)
by NOT hitting the database immediately.
Do NOT call this method unless you are SURE that the object with the supplied identifier exists.
persistentClass
- the type of the entity to loadid
- unique identifier to load.public Object loadReference(long id)
session.load
method to
obtain a proxy (or actual instance if the object is in session)
by NOT hitting the database immediately.
Do NOT call this method unless you are SURE that the object with the supplied identifier exists.
id
- unique identifier to load.public void remove(Object persistentObject) throws org.springframework.dao.DataAccessException
persistentObject
- The object to remove.org.springframework.dao.DataAccessException
- A persistence exception has occurred.public void save(Object persistentObject) throws org.springframework.dao.DataAccessException
persistentObject
- The object to save.org.springframework.dao.DataAccessException
- A persistence exception has occurred.public void saveOrUpdate(Object persistentObject) throws org.springframework.dao.DataAccessException
persistentObject
- The object to save or update.org.springframework.dao.DataAccessException
- A persistence exception has occurred.@Autowired public void setBatchFinder(BatchFinder batchFinder)
@Autowired public void setBatchProcessor(SessionBatchProcessor batchProcessor)
@Autowired public void setStatelessSessionBatchProcessor(StatelessSessionBatchProcessor statelessSessionBatchProcessor)
public void update(Object persistentObject) throws org.springframework.dao.DataAccessException
persistentObject
- The object to update.org.springframework.dao.DataAccessException
- A persistence exception has occurred.protected org.hibernate.Session session()
protected org.hibernate.query.Query createHibernateQuery(HQLQuery hqlQuery)
public void setClock(Clock timeSource)
Copyright © 2017 Atlassian. All rights reserved.