org.figure8.join.core.persistence
Class HibernateObjectDao

java.lang.Object
  extended by org.springframework.orm.hibernate.support.HibernateDaoSupport
      extended by org.figure8.join.core.persistence.HibernateObjectDao
All Implemented Interfaces:
ObjectDao, org.springframework.beans.factory.InitializingBean
Direct Known Subclasses:
GenericHibernateObjectDao, HibernateAssemblyDao, HibernateBuildDao, HibernateComponentDao, HibernateComponentTypeDao, HibernateDeliverableDao, HibernateDeliverableTypeDao, HibernateDeploymentDao, HibernateEISMappingDao, HibernateEnvironmentMappingDao, HibernateEventDao, HibernateJMSConsumerBeanInfoDao, HibernateLogicalEnvironmentDao, HibernateMachineDao, HibernateMailingListDao, HibernateMessageDao, HibernateParameterDao, HibernateParameterValueDao, HibernatePermissionDao, HibernatePhysicalEnvironmentDao, HibernateQuartzCronInfoDao, HibernateReleaseDao, HibernateResourceDao, HibernateResourceMappingDao, HibernateResourceTypeDao, HibernateResourceVersionDao, HibernateRoleDao, HibernateScriptLogInfoDao, HibernateStatusDao, HibernateStepDao, HibernateSubscriptionDao, HibernateTargetDao, HibernateUserDao, HibernateVersionedResourceUpdateDao

public abstract class HibernateObjectDao
extends org.springframework.orm.hibernate.support.HibernateDaoSupport
implements ObjectDao

This is a base class for Dao implementations using Hibernate as their ORM solution. This base class also extends Spring container Hibernate support class in order to use Spring's features such as declarative transaction demarcation ...

Version:
$Revision: 1.3 $
Author:
Laurent Broudoux

Field Summary
protected  org.apache.commons.logging.Log log
          Logger
 
Fields inherited from class org.springframework.orm.hibernate.support.HibernateDaoSupport
logger
 
Constructor Summary
HibernateObjectDao()
          Default constructor.
 
Method Summary
 java.util.List findAll()
          Find all entity objects associated with this Dao.
 java.util.List findAllSorted(java.lang.String sortField)
          Find all entity objects asscoiated with this Dao.
protected  java.util.List findNamedQuery(java.lang.String queryName)
          Execute a named query defined in a Hibernate mapping file.
protected  java.util.List findNamedQuery(java.lang.String queryName, boolean cacheable)
          Execute a named query defined in a Hibernate mapping file.
protected  java.util.List findNamedQuery(java.lang.String queryName, boolean cacheable, int maxResultCount)
          Execute a named query defined in a Hibernate mapping file.
protected  java.util.List findNamedQueryStringParam(java.lang.String queryName, java.lang.String paramName, java.lang.Object paramValue)
          Execute a named query with one param defined in a Hibernate mapping file.
protected  java.util.List findNamedQueryStringParam(java.lang.String queryName, java.lang.String paramName, java.lang.Object paramValue, boolean cacheable)
          Execute a named query with one param defined in a Hibernate mapping file.
protected  java.util.List findNamedQueryStringParam(java.lang.String queryName, java.lang.String paramName, java.lang.Object paramValue, boolean cacheable, int maxResultCount)
          Execute a named query with one param defined in a Hibernate mapping file.
protected  java.util.List findNamedQueryStringParams(java.lang.String queryName, java.lang.String paramName, java.lang.Object paramValue, java.lang.String param2Name, java.lang.Object param2Value)
          Execute a named query with two params defined in a Hibernate mapping file.
protected  java.util.List findNamedQueryStringParams(java.lang.String queryName, java.lang.String paramName, java.lang.Object paramValue, java.lang.String param2Name, java.lang.Object param2Value, boolean cacheable)
          Execute a named query with two params defined in a Hibernate mapping file.
protected  java.util.List findNamedQueryStringParams(java.lang.String queryName, java.lang.String paramName, java.lang.Object paramValue, java.lang.String param2Name, java.lang.Object param2Value, java.lang.String param3Name, java.lang.Object param3Value)
          Execute a named query with three params defined in a Hibernate mapping file.
protected  java.util.List findNamedQueryStringParams(java.lang.String queryName, java.lang.String paramName, java.lang.Object paramValue, java.lang.String param2Name, java.lang.Object param2Value, java.lang.String param3Name, java.lang.Object param3Value, boolean cacheable)
          Execute a named query with two params defined in a Hibernate mapping file.
protected  java.util.List findNamedQueryStringParams(java.lang.String queryName, java.lang.String paramName, java.lang.Object paramValue, java.lang.String param2Name, java.lang.Object param2Value, java.lang.String param3Name, java.lang.Object param3Value, boolean cacheable, int maxResultCount)
          Execute a named query with two params defined in a Hibernate mapping file.
protected  java.lang.Object findSingleObject(java.util.List results)
          Filter a list of results that should only contain one element
protected  EntityObject getById(long id)
          Retrieve an object of the persistent class using its unique identifier (primary key)
 void initialize(EntityObject entityobject)
          Force initialization of the given entity from underlying datastore (this may involves initialization of lazily loaded relations fields)
 void initializeAssociation(EntityObject entityobject, java.lang.Object proxy)
          Force initialization of the given entity association from underlying datastore
 boolean isInitialized(java.lang.Object object)
          Check if an object (EntityObject or association proxy) is initialized from datastore
 void refresh(EntityObject entityobject)
          Re-read the content of the given entity from underlying datastore.
 void remove(EntityObject entityobject)
          Remove the given entity object from underlying datastore.
 void replicate(java.lang.Object obj)
          Persist the object state throughout the cluster.
 void save(EntityObject entityobject)
          Save the given entity into underlying datastore.
 
Methods inherited from class org.springframework.orm.hibernate.support.HibernateDaoSupport
afterPropertiesSet, closeSessionIfNecessary, convertHibernateAccessException, createHibernateTemplate, getHibernateTemplate, getSession, getSession, getSessionFactory, initDao, setHibernateTemplate, setSessionFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.figure8.join.core.persistence.ObjectDao
getPersistentClass
 

Field Detail

log

protected org.apache.commons.logging.Log log
Logger

Constructor Detail

HibernateObjectDao

public HibernateObjectDao()
Default constructor.

Method Detail

save

public void save(EntityObject entityobject)
Save the given entity into underlying datastore.

Specified by:
save in interface ObjectDao
Parameters:
entityobject - EntityObject to save

remove

public void remove(EntityObject entityobject)
Remove the given entity object from underlying datastore.

Specified by:
remove in interface ObjectDao
Parameters:
entityobject - EntityObject to remove

refresh

public void refresh(EntityObject entityobject)
Re-read the content of the given entity from underlying datastore.

Specified by:
refresh in interface ObjectDao
Parameters:
entityobject - EntityObject to refresh content

initialize

public void initialize(EntityObject entityobject)
Force initialization of the given entity from underlying datastore (this may involves initialization of lazily loaded relations fields)

Specified by:
initialize in interface ObjectDao
Parameters:
entityobject - EntityObject to initialize

initializeAssociation

public void initializeAssociation(EntityObject entityobject,
                                  java.lang.Object proxy)
Force initialization of the given entity association from underlying datastore

Specified by:
initializeAssociation in interface ObjectDao
Parameters:
entityobject - EntityObject whose association shoud be initialized
proxy - A proxy object representing entoty association (this may be a collection)

isInitialized

public boolean isInitialized(java.lang.Object object)
Check if an object (EntityObject or association proxy) is initialized from datastore

Specified by:
isInitialized in interface ObjectDao
Parameters:
object - The object to check initialization for
Returns:
true if object has been loaded from datastore, false otherwise

replicate

public void replicate(java.lang.Object obj)
Persist the object state throughout the cluster.

Specified by:
replicate in interface ObjectDao
Parameters:
obj - The object to replicate

findAll

public java.util.List findAll()
Find all entity objects associated with this Dao.

Specified by:
findAll in interface ObjectDao
Returns:
A List of EntityObjects

findAllSorted

public java.util.List findAllSorted(java.lang.String sortField)
Find all entity objects asscoiated with this Dao. The result list is sorted by sortField criteria.

Specified by:
findAllSorted in interface ObjectDao
Parameters:
sortField - Field for sorting criteria
Returns:
A List of EntityObjects

getById

protected EntityObject getById(long id)
Retrieve an object of the persistent class using its unique identifier (primary key)

Parameters:
id - The identifier of the persistent object to retrieve
Returns:
The EntityObject corresponding to id

findNamedQuery

protected java.util.List findNamedQuery(java.lang.String queryName)
Execute a named query defined in a Hibernate mapping file. Query will not be cached.

Parameters:
queryName - Name of the query to execute
Returns:
List of entity objects

findNamedQuery

protected java.util.List findNamedQuery(java.lang.String queryName,
                                        boolean cacheable)
Execute a named query defined in a Hibernate mapping file.

Parameters:
queryName - Name of the query to execute
cacheable - wether the query is cached or not
Returns:
List of entity objects

findNamedQuery

protected java.util.List findNamedQuery(java.lang.String queryName,
                                        boolean cacheable,
                                        int maxResultCount)
Execute a named query defined in a Hibernate mapping file.

Parameters:
queryName - Name of the query to execute
cacheable - wether the query is cached or not
maxResultCount - Max number of results
Returns:
List of entity objects

findNamedQueryStringParam

protected java.util.List findNamedQueryStringParam(java.lang.String queryName,
                                                   java.lang.String paramName,
                                                   java.lang.Object paramValue)
Execute a named query with one param defined in a Hibernate mapping file. Query will not be cached.

Parameters:
queryName - Name of the query to execute
paramName - Name of the query parameter
paramValue - Value of the query parameter
Returns:
List of entity objects

findNamedQueryStringParam

protected java.util.List findNamedQueryStringParam(java.lang.String queryName,
                                                   java.lang.String paramName,
                                                   java.lang.Object paramValue,
                                                   boolean cacheable)
Execute a named query with one param defined in a Hibernate mapping file.

Parameters:
queryName - Name of the query to execute
paramName - Name of the query parameter
paramValue - Value of the query parameter
cacheable - wether the query is cached or not
Returns:
List of entity objects

findNamedQueryStringParam

protected java.util.List findNamedQueryStringParam(java.lang.String queryName,
                                                   java.lang.String paramName,
                                                   java.lang.Object paramValue,
                                                   boolean cacheable,
                                                   int maxResultCount)
Execute a named query with one param defined in a Hibernate mapping file.

Parameters:
queryName - Name of the query to execute
paramName - Name of the query parameter
paramValue - Value of the query parameter
cacheable - wether the query is cached or not
maxResultCount - Max number of results
Returns:
List of entity objects

findNamedQueryStringParams

protected java.util.List findNamedQueryStringParams(java.lang.String queryName,
                                                    java.lang.String paramName,
                                                    java.lang.Object paramValue,
                                                    java.lang.String param2Name,
                                                    java.lang.Object param2Value)
Execute a named query with two params defined in a Hibernate mapping file. Query will not be cached.

Parameters:
queryName - Name of the query to execute
paramName - Name of the query parameter
paramValue - Value of the query parameter
param2Name - Name of the 2nd query parameter
param2Value - Value of the 2nd query parameter
Returns:
List of entity objects

findNamedQueryStringParams

protected java.util.List findNamedQueryStringParams(java.lang.String queryName,
                                                    java.lang.String paramName,
                                                    java.lang.Object paramValue,
                                                    java.lang.String param2Name,
                                                    java.lang.Object param2Value,
                                                    boolean cacheable)
Execute a named query with two params defined in a Hibernate mapping file.

Parameters:
queryName - Name of the query to execute
paramName - Name of the query parameter
paramValue - Value of the query parameter
param2Name - Name of the 2nd query parameter
param2Value - Value of the 2nd query parameter
cacheable - wether the query is cached or not
Returns:
List of entity objects

findNamedQueryStringParams

protected java.util.List findNamedQueryStringParams(java.lang.String queryName,
                                                    java.lang.String paramName,
                                                    java.lang.Object paramValue,
                                                    java.lang.String param2Name,
                                                    java.lang.Object param2Value,
                                                    java.lang.String param3Name,
                                                    java.lang.Object param3Value)
Execute a named query with three params defined in a Hibernate mapping file. Query will not be cached.

Parameters:
queryName - Name of the query to execute
paramName - Name of the query parameter
paramValue - Value of the query parameter
param2Name - Name of the 2nd query parameter
param2Value - Value of the 2nd query parameter
param3Name - Name of the 3rd query parameter
param3Value - Value of the 3rd query parameter
Returns:
List of entity objects

findNamedQueryStringParams

protected java.util.List findNamedQueryStringParams(java.lang.String queryName,
                                                    java.lang.String paramName,
                                                    java.lang.Object paramValue,
                                                    java.lang.String param2Name,
                                                    java.lang.Object param2Value,
                                                    java.lang.String param3Name,
                                                    java.lang.Object param3Value,
                                                    boolean cacheable)
Execute a named query with two params defined in a Hibernate mapping file.

Parameters:
queryName - Name of the query to execute
paramName - Name of the query parameter
paramValue - Value of the query parameter
param2Name - Name of the 2nd query parameter
param2Value - Value of the 2nd query parameter
param3Name - Name of the 3rd query parameter
param3Value - Value of the 3rd query parameter
cacheable - wether the query is cached or not
Returns:
List of entity objects

findNamedQueryStringParams

protected java.util.List findNamedQueryStringParams(java.lang.String queryName,
                                                    java.lang.String paramName,
                                                    java.lang.Object paramValue,
                                                    java.lang.String param2Name,
                                                    java.lang.Object param2Value,
                                                    java.lang.String param3Name,
                                                    java.lang.Object param3Value,
                                                    boolean cacheable,
                                                    int maxResultCount)
Execute a named query with two params defined in a Hibernate mapping file.

Parameters:
queryName - Name of the query to execute
paramName - Name of the query parameter
paramValue - Value of the query parameter
param2Name - Name of the 2nd query parameter
param2Value - Value of the 2nd query parameter
param3Name - Name of the 3rd query parameter
param3Value - Value of the 3rd query parameter
cacheable - wether the query is cached or not
maxResultCount - Max number of results
Returns:
List of entity objects

findSingleObject

protected java.lang.Object findSingleObject(java.util.List results)
Filter a list of results that should only contain one element

Parameters:
results - The list of results to filter
Returns:
The element if it is the only one, otherwise log an error and return null


Copyright © 2005-2008 Join. All Rights Reserved.