net.sf.hibernate4gwt.core
Class LazyKiller

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

public class LazyKiller
extends java.lang.Object

This class replaces all "lazy but not loaded" Hibernate association with null to allow the argument POJO to be used in other libraries without additional loading of 'LazyInitializationException'. The lazy properties are stored as string. They can be reused for "reattaching" the clone pojo to a fresh Hibernate object.

Author:
bruno.marchesson

Constructor Summary
LazyKiller()
          Empty constructor
LazyKiller(IClassMapper classMapper, IPersistenceUtil persistenceUtil, IPojoStore pojoStore)
          Base constructor
 
Method Summary
 void attach(java.lang.Object hibernatePojo, java.lang.Object clonePojo)
          Hibernate attachment
protected  java.lang.Object clone(java.lang.Object hibernatePojo, java.lang.Class cloneClass)
          Clone the abstract POJO with BeanLib Every time a lazy property is detected, it is replaced with null.
 java.lang.Object detach(java.lang.Object hibernatePojo)
          Hibernate detachment
 java.lang.Object detach(java.lang.Object hibernatePojo, java.lang.Class cloneClass)
          Hibernate detachment
 IPersistenceUtil getPersistenceUtil()
           
 IPojoStore getPojoStore()
           
 void populate(java.lang.Object hibernatePojo, java.lang.Object clonePojo)
          Populate the hibernatePojo (a fresh new one or the one used to clone) with the clone detached object.
 void setClassMapper(IClassMapper mapper)
           
 void setPersistenceUtil(IPersistenceUtil util)
           
 void setPojoStore(IPojoStore store)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LazyKiller

public LazyKiller()
Empty constructor


LazyKiller

public LazyKiller(IClassMapper classMapper,
                  IPersistenceUtil persistenceUtil,
                  IPojoStore pojoStore)
Base constructor

Parameters:
classMapper - the class mapping service
persistenceUtil - persistence util implementation
-
Method Detail

getPersistenceUtil

public IPersistenceUtil getPersistenceUtil()
Returns:
the persistence Util implementation to use

setPersistenceUtil

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

setClassMapper

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

getPojoStore

public IPojoStore getPojoStore()
Returns:
the associated pojo Store

setPojoStore

public void setPojoStore(IPojoStore store)
Parameters:
store - the POJO Store to set

detach

public java.lang.Object detach(java.lang.Object hibernatePojo)
Hibernate detachment

Parameters:
hibernatePojo - the input hibernate pojo
Returns:
a pure Java clone

detach

public java.lang.Object detach(java.lang.Object hibernatePojo,
                               java.lang.Class cloneClass)
Hibernate detachment

Parameters:
hibernatePojo - the input hibernate pojo
Returns:
a pure Java clone

attach

public void attach(java.lang.Object hibernatePojo,
                   java.lang.Object clonePojo)
Hibernate attachment

Parameters:
hibernatePojo - the stored or fresh Hibernate POJO
clonePojo - the cloned pojo

clone

protected java.lang.Object clone(java.lang.Object hibernatePojo,
                                 java.lang.Class cloneClass)
Clone the abstract POJO with BeanLib Every time a lazy property is detected, it is replaced with null. It is also marked as "lazy" for ILazyPojo sub-classes

Parameters:
pojo -
Returns:

populate

public void populate(java.lang.Object hibernatePojo,
                     java.lang.Object clonePojo)
Populate the hibernatePojo (a fresh new one or the one used to clone) with the clone detached object. This Hibernate POJO holds the lazy properties information