com.atlassian.crowd.util.persistence.hibernate
Class HibernateDao

java.lang.Object
  extended by com.atlassian.crowd.util.persistence.hibernate.HibernateDao
Direct Known Subclasses:
AliasDAOHibernate, ApplicationDAOHibernate, DirectoryDAOHibernate, GroupDAOHibernate, MembershipDAOHibernate, PropertyDAOHibernate, TokenDAOHibernate, UserDAOHibernate, WebhookDAOHibernate

public abstract class HibernateDao
extends Object

Generic persistence class for storing Hibernate persistence objects.


Field Summary
protected  BatchFinder batchFinder
           
protected  BatchProcessor<org.hibernate.Session> batchProcessor
           
protected  org.slf4j.Logger logger
           
protected  org.hibernate.SessionFactory sessionFactory
           
 
Constructor Summary
HibernateDao()
           
 
Method Summary
protected  org.hibernate.Query createHibernateQuery(Query crowdQuery, HQLQuery hqlQuery)
          Creates a Hibernate Query equivalent to the provided Crowd Query and HQLQuery.
abstract  Class getPersistentClass()
          All subclasses of HibernateDao must implement this method for load(long) to work correctly.
<T> T
load(Class<T> persistentClass, long id)
          Loads a persisted entity from the persistence store.
 Object load(long 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(BatchProcessor batchProcessor)
           
 void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
           
 void update(Object persistentObject)
          Updates an existing DAO object, if the object does not exist it will be added to the persistence store.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.slf4j.Logger logger

batchFinder

protected BatchFinder batchFinder

batchProcessor

protected BatchProcessor<org.hibernate.Session> batchProcessor

sessionFactory

protected org.hibernate.SessionFactory sessionFactory
Constructor Detail

HibernateDao

public HibernateDao()
Method Detail

getPersistentClass

public abstract Class getPersistentClass()
All subclasses of HibernateDao must implement this method for load(long) to work correctly.

Returns:
the entity class for this DAO

load

public <T> T load(Class<T> persistentClass,
                  long id)
       throws ObjectNotFoundException
Loads a persisted entity from the persistence store.

Parameters:
persistentClass - The entity type to load
id - The unique identifier of the object to load from the persistence store.
Returns:
The populated object from the database.
Throws:
ObjectNotFoundException - when the requested entity is not found.

load

public Object load(long id)
            throws ObjectNotFoundException
Loads a persisted entity from the persistence store.

Parameters:
id - The unique identifier of the object to load from the persistence store.
Returns:
The populated object from the database.
Throws:
ObjectNotFoundException - when the requested entity is not found.

loadReference

public <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.

Do NOT call this method unless you are SURE that the object with the supplied identifier exists.

Parameters:
persistentClass - the type of the entity to load
id - unique identifier to load.
Returns:
a proxy object (or actual instance if the object is in session)

loadReference

public 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.

Do NOT call this method unless you are SURE that the object with the supplied identifier exists.

Parameters:
id - unique identifier to load.
Returns:
a proxy object (or actual instance if the object is in session)

remove

public void remove(Object persistentObject)
            throws org.springframework.dao.DataAccessException
Removes the DAO object from the persistence store.

Parameters:
persistentObject - The object to remove.
Throws:
org.springframework.dao.DataAccessException - A persistence exception has occurred.

save

public void save(Object persistentObject)
          throws org.springframework.dao.DataAccessException
Saves a new DAO object to the persistence store.

Parameters:
persistentObject - The object to save.
Throws:
org.springframework.dao.DataAccessException - A persistence exception has occurred.

saveOrUpdate

public void saveOrUpdate(Object persistentObject)
                  throws org.springframework.dao.DataAccessException
Saves or updates DAO object to the persistence store.

Parameters:
persistentObject - The object to save or update.
Throws:
org.springframework.dao.DataAccessException - A persistence exception has occurred.

setBatchFinder

@Autowired
public void setBatchFinder(BatchFinder batchFinder)

setBatchProcessor

@Autowired
public void setBatchProcessor(BatchProcessor batchProcessor)

setSessionFactory

@Autowired
public void setSessionFactory(org.hibernate.SessionFactory sessionFactory)

update

public void update(Object persistentObject)
            throws org.springframework.dao.DataAccessException
Updates an existing DAO object, if the object does not exist it will be added to the persistence store.

Parameters:
persistentObject - The object to update.
Throws:
org.springframework.dao.DataAccessException - A persistence exception has occurred.

session

protected org.hibernate.Session session()

createHibernateQuery

protected org.hibernate.Query createHibernateQuery(Query crowdQuery,
                                                   HQLQuery hqlQuery)
Creates a Hibernate Query equivalent to the provided Crowd Query and HQLQuery.

Parameters:
crowdQuery -
hqlQuery -
Returns:
a Hibernate query


Copyright © 2013 Atlassian. All Rights Reserved.