net.sf.hibernate4gwt.core
Class HibernateBeanManager

java.lang.Object
  extended by net.sf.hibernate4gwt.core.HibernateBeanManager

public class HibernateBeanManager
extends java.lang.Object

Manager for Hibernate POJO handling

Author:
bruno.marchesson

Field Summary
protected  IClassMapper _classMapper
          The Class mapper
protected  LazyKiller _lazyKiller
          The POJO lazy killer
protected  IPersistenceUtil _persistenceUtil
          The associated persistence util implementation
protected  IPojoStore _pojoStore
          The associated POJO Handler
 
Constructor Summary
HibernateBeanManager()
          Empty Constructor
 
Method Summary
 java.lang.Object clone(java.lang.Object object)
          Clone and store the Hibernate POJO(s)
 java.lang.Object clone(java.lang.Object object, boolean assignable)
          Clone and store the Hibernate POJO
protected  java.util.Collection cloneCollection(java.util.Collection hibernatePojoList, boolean assignable)
          Clone and store a collection of Hibernate POJO
protected  java.util.Map cloneMap(java.util.Map hibernatePojoMap, boolean assignable)
          Clone and store a map of Hibernate POJO
protected  java.lang.Object clonePojo(java.lang.Object pojo, boolean assignable)
          Clone and store the Hibernate POJO
protected  java.util.Collection<java.lang.Object> createNewCollection(java.util.Collection<?> pojoCollection)
          Create a new collection with the same behavior than the argument one
protected  java.util.Map createNewMap(java.util.Map pojoMap)
          Create a new map with the same behavior than the argument one
 IClassMapper getClassMapper()
           
static HibernateBeanManager getInstance()
           
 IPersistenceUtil getPersistenceUtil()
           
 IPojoStore getPojoStore()
           
protected  boolean holdPersistentObject(java.lang.Object pojo)
          In deep persistent association checking.
 java.lang.Object merge(java.lang.Object object)
          Merge the clone POJO to its Hibernate counterpart
 java.lang.Object merge(java.lang.Object object, boolean assignable)
          Merge the clone POJO to its Hibernate counterpart
protected  java.util.Collection mergeCollection(java.util.Collection clonePojoList, boolean assignable)
          Retrieve the Hibernate Pojo List and merge the modification from GWT
protected  java.util.Map mergeMap(java.util.Map cloneMap, boolean assignable)
          Fill copy map with Hibernate merged POJO
protected  java.lang.Object mergePojo(java.lang.Object clonePojo, boolean assignable)
          Retrieve the Hibernate Pojo and merge the modification from GWT
 void remove(java.lang.Object object)
          Remove the object of the pojo store
protected  void removeCollection(java.util.Collection pojoList)
          Remove the collection of pojo from the pojo store
protected  void removeMap(java.util.Map pojoMap)
          Remove the content of the map of pojo from the pojo store
protected  void removePojo(java.lang.Object pojo)
          Remove the pojo from the pojo store
 void setClassMapper(IClassMapper mapper)
           
 void setEntityManagerFactory(java.lang.Object entityManagerFactory)
          Helper setter to initialize HibernateHelper with the embedded Hibernate SessionFactory.
 void setPersistenceUtil(IPersistenceUtil util)
           
 void setPojoStore(IPojoStore pojoStore)
          set the used pojo store
 void setSessionFactory(SessionFactory sessionFactory)
          Helper setter to initialize HibernateHelper Must be called on startup !
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_pojoStore

protected IPojoStore _pojoStore
The associated POJO Handler


_classMapper

protected IClassMapper _classMapper
The Class mapper


_lazyKiller

protected LazyKiller _lazyKiller
The POJO lazy killer


_persistenceUtil

protected IPersistenceUtil _persistenceUtil
The associated persistence util implementation

Constructor Detail

HibernateBeanManager

public HibernateBeanManager()
Empty Constructor

Method Detail

getInstance

public static HibernateBeanManager getInstance()
Returns:
the unique instance of the singleton

getPojoStore

public IPojoStore getPojoStore()
Returns:
the pojo store

setPojoStore

public void setPojoStore(IPojoStore pojoStore)
set the used pojo store


getClassMapper

public IClassMapper getClassMapper()
Returns:
the class mapper

setClassMapper

public void setClassMapper(IClassMapper mapper)
Parameters:
mapper - the class Mapper to set

setSessionFactory

public void setSessionFactory(SessionFactory sessionFactory)
Helper setter to initialize HibernateHelper Must be called on startup !


setEntityManagerFactory

public void setEntityManagerFactory(java.lang.Object entityManagerFactory)
Helper setter to initialize HibernateHelper with the embedded Hibernate SessionFactory. Will not work with other JPA entity manager Lust be called on startup !


getPersistenceUtil

public IPersistenceUtil getPersistenceUtil()
Returns:
the _persistenceUtil

setPersistenceUtil

public void setPersistenceUtil(IPersistenceUtil util)
Parameters:
util - the _persistenceUtil to set

clone

public java.lang.Object clone(java.lang.Object object)
Clone and store the Hibernate POJO(s)


clone

public java.lang.Object clone(java.lang.Object object,
                              boolean assignable)
Clone and store the Hibernate POJO

Parameters:
object - the object to store
assignable - if the assignation from source to target class (via ClassMapper) must be checked
Returns:
the clone

merge

public java.lang.Object merge(java.lang.Object object)
Merge the clone POJO to its Hibernate counterpart


merge

public java.lang.Object merge(java.lang.Object object,
                              boolean assignable)
Merge the clone POJO to its Hibernate counterpart


remove

public void remove(java.lang.Object object)
Remove the object of the pojo store


clonePojo

protected java.lang.Object clonePojo(java.lang.Object pojo,
                                     boolean assignable)
Clone and store the Hibernate POJO

Parameters:
pojo - the pojo to store
assignable - does the source and target class must be assignable?
Throws:
NotAssignableException - if source and target class are not assignable

cloneMap

protected java.util.Map cloneMap(java.util.Map hibernatePojoMap,
                                 boolean assignable)
Clone and store a map of Hibernate POJO


cloneCollection

protected java.util.Collection cloneCollection(java.util.Collection hibernatePojoList,
                                               boolean assignable)
Clone and store a collection of Hibernate POJO


mergePojo

protected java.lang.Object mergePojo(java.lang.Object clonePojo,
                                     boolean assignable)
Retrieve the Hibernate Pojo and merge the modification from GWT

Parameters:
clonePojo - the clone pojo
assignable - does the source and target class must be assignable
Returns:
the merged Hibernate POJO
Throws:
java.lang.UnsupportedOperationException - if the clone POJO does not implements ILazyPojo and the POJO store is stateless
NotAssignableException - if source and target class are not assignable

mergeCollection

protected java.util.Collection mergeCollection(java.util.Collection clonePojoList,
                                               boolean assignable)
Retrieve the Hibernate Pojo List and merge the modification from GWT

Parameters:
clonePojoList - the clone pojo list
Returns:
a list of merged Hibernate POJO
Throws:
java.lang.UnsupportedOperationException - if a POJO from the list does not implements ILazyPojo and the POJO store is stateless

mergeMap

protected java.util.Map mergeMap(java.util.Map cloneMap,
                                 boolean assignable)
Fill copy map with Hibernate merged POJO

Parameters:
cloneMap -
Returns:
a map with merge Hibernate POJO

removePojo

protected void removePojo(java.lang.Object pojo)
Remove the pojo from the pojo store

Parameters:
pojo - hibernate pojo

removeMap

protected void removeMap(java.util.Map pojoMap)
Remove the content of the map of pojo from the pojo store

Parameters:
pojoList - hibernate pojo list

removeCollection

protected void removeCollection(java.util.Collection pojoList)
Remove the collection of pojo from the pojo store

Parameters:
pojoList - hibernate pojo collection

createNewCollection

protected java.util.Collection<java.lang.Object> createNewCollection(java.util.Collection<?> pojoCollection)
Create a new collection with the same behavior than the argument one

Parameters:
pojoCollection - the source collection
Returns:
a newly created, empty collection

createNewMap

protected java.util.Map createNewMap(java.util.Map pojoMap)
Create a new map with the same behavior than the argument one

Parameters:
pojoMap - the source map
Returns:
a newly created, empty map

holdPersistentObject

protected boolean holdPersistentObject(java.lang.Object pojo)
In deep persistent association checking. This method is used to detect wrapping object (ie not persistent class holding persistent associations)

Parameters:
pojo - the wrapping pojo
Returns:
true if the pojo contains persistent member, false otherwise