org.wamblee.persistence.hibernate
Class HibernateSupport

java.lang.Object
  extended by org.springframework.dao.support.DaoSupport
      extended by org.springframework.orm.hibernate3.support.HibernateDaoSupport
          extended by org.wamblee.persistence.hibernate.HibernateSupport
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean

public class HibernateSupport
extends org.springframework.orm.hibernate3.support.HibernateDaoSupport

Extension of org.springframework.orm.hibernate.support.HibernateDaoSupport.

Author:
Erik Brakkee

Field Summary
 
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
 
Constructor Summary
HibernateSupport()
          Constructs the object.
 
Method Summary
static void merge(org.springframework.orm.hibernate3.HibernateTemplate aTemplate, Persistent aPersistent)
          As merge(Persistent) but with a given template.
 void merge(Persistent aPersistent)
          Performes a hibernate Session.merge() and updates the object with the correct primary key and version.
static void processList(java.util.List aPersistent, java.util.List aMerged, java.util.List<org.wamblee.persistence.hibernate.HibernateSupport.ObjectElem> aProcessed)
          Process the persistent objects in the collections.
static
<Key,Value>
void
processMap(java.util.Map<Key,Value> aPersistent, java.util.Map<Key,Value> aMerged, java.util.List<org.wamblee.persistence.hibernate.HibernateSupport.ObjectElem> aProcessed)
          Process the Map objects in the collections.
static void processPersistent(Persistent aPersistent, Persistent aMerged, java.util.List<org.wamblee.persistence.hibernate.HibernateSupport.ObjectElem> aProcessed)
          Copies primary keys and version from the result of the merged to the object that was passed to the merge operation.
static void processSet(java.util.Set aPersistent, java.util.Set aMerged, java.util.List<org.wamblee.persistence.hibernate.HibernateSupport.ObjectElem> aProcessed)
          Process the persistent objects in sets.
 
Methods inherited from class org.springframework.orm.hibernate3.support.HibernateDaoSupport
checkDaoConfig, convertHibernateAccessException, createHibernateTemplate, getHibernateTemplate, getSession, getSession, getSessionFactory, releaseSession, setHibernateTemplate, setSessionFactory
 
Methods inherited from class org.springframework.dao.support.DaoSupport
afterPropertiesSet, initDao
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HibernateSupport

public HibernateSupport()
Constructs the object.

Method Detail

merge

public void merge(Persistent aPersistent)
Performes a hibernate Session.merge() and updates the object with the correct primary key and version. This is an extension to the hibernate merge operation because hibernate itself leaves the object passed to merge untouched. Use this method with extreme caution since it will recursively load all objects that the current object has relations with and for which cascade="merge" was specified in the Hibernate mapping file.

Parameters:
aPersistent - Object to merge.

merge

public static void merge(org.springframework.orm.hibernate3.HibernateTemplate aTemplate,
                         Persistent aPersistent)
As merge(Persistent) but with a given template. This method can be accessed in a static way.

Parameters:
aTemplate - Hibernate template
aPersistent - Object to merge.

processPersistent

public static void processPersistent(Persistent aPersistent,
                                     Persistent aMerged,
                                     java.util.List<org.wamblee.persistence.hibernate.HibernateSupport.ObjectElem> aProcessed)
Copies primary keys and version from the result of the merged to the object that was passed to the merge operation. It does this by traversing the properties of the object. It copies the primary key and version for objects that implement Persistent and applies the same rules to objects in maps and sets as well (i.e. recursively).

Parameters:
aPersistent - Object whose primary key and version are to be set.
aMerged - Object that was the result of the merge.
aProcessed - List of already processed Persistent objects of the persistent part.

processList

public static void processList(java.util.List aPersistent,
                               java.util.List aMerged,
                               java.util.List<org.wamblee.persistence.hibernate.HibernateSupport.ObjectElem> aProcessed)
Process the persistent objects in the collections.

Parameters:
aPersistent - Collection in the original object.
aMerged - Collection as a result of the merge.
aProcessed - List of processed persistent objects.

processSet

public static void processSet(java.util.Set aPersistent,
                              java.util.Set aMerged,
                              java.util.List<org.wamblee.persistence.hibernate.HibernateSupport.ObjectElem> aProcessed)
Process the persistent objects in sets.

Parameters:
aPersistent - Collection in the original object.
aMerged - Collection as a result of the merge.
aProcessed - List of processed persistent objects.

processMap

public static <Key,Value> void processMap(java.util.Map<Key,Value> aPersistent,
                                          java.util.Map<Key,Value> aMerged,
                                          java.util.List<org.wamblee.persistence.hibernate.HibernateSupport.ObjectElem> aProcessed)
Process the Map objects in the collections.

Parameters:
aPersistent - Collection in the original object.
aMerged - Collection as a result of the merge.
aProcessed - List of processed persistent objects.


Copyright © 2010. All Rights Reserved.