org.compass.gps.device.hibernate.lifecycle
Class DefaultHibernateEntityLifecycleInjector

java.lang.Object
  extended by org.compass.gps.device.hibernate.lifecycle.DefaultHibernateEntityLifecycleInjector
All Implemented Interfaces:
HibernateEntityLifecycleInjector
Direct Known Subclasses:
DefaultHibernateEntityCollectionLifecycleInjector

public class DefaultHibernateEntityLifecycleInjector
extends Object
implements HibernateEntityLifecycleInjector

Injects lifecycle listeners directly into Hibernate for mirroring operations.

By default, registers with plain insert/update/delete listeners, which will be triggered by Hibernate before committing (and up to Hibernate flushing logic). Also allows to be created with setting the registerPostCommitListeneres to true which will cause the insert/update/delete listeneres to be registered as post commit events.

Author:
kimchy

Field Summary
protected  boolean marshallIds
           
protected  boolean pendingCascades
           
protected  boolean processCollection
           
protected  boolean registerPostCommitListeneres
           
 
Constructor Summary
DefaultHibernateEntityLifecycleInjector()
           
DefaultHibernateEntityLifecycleInjector(boolean registerPostCommitListeneres)
          Creates a new lifecycle injector.
 
Method Summary
protected  Object doCreateListener(HibernateGpsDevice device)
           
 void injectLifecycle(SessionFactory sessionFactory, HibernateGpsDevice device)
          Injects a global lifecycle listener into the concrete SessionFactory implementation.
 void removeLifecycle(SessionFactory sessionFactory, HibernateGpsDevice device)
          Removes (if possible) lifecycle listeners injected using the inject method.
 void setMarshallIds(boolean marshallIds)
          Should the listener try and marshall ids for the event listener of post insert.
 void setPendingCascades(boolean pendingCascades)
          Should the listener try and handle pending cascades avoiding trying to save/update relationships in Compass before they were processed by Hibernate.
 void setProcessCollection(boolean processCollection)
          Should the event listener automatically set the processed flag on collections that are created as a result of the marshalling process of Compass.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

registerPostCommitListeneres

protected boolean registerPostCommitListeneres

marshallIds

protected boolean marshallIds

pendingCascades

protected boolean pendingCascades

processCollection

protected boolean processCollection
Constructor Detail

DefaultHibernateEntityLifecycleInjector

public DefaultHibernateEntityLifecycleInjector()

DefaultHibernateEntityLifecycleInjector

public DefaultHibernateEntityLifecycleInjector(boolean registerPostCommitListeneres)
Creates a new lifecycle injector. Allows to control if the insert/update/delete even listeners will be registered with post commit listeres (flag it true) or with plain post events (triggered based on Hibrenate flushing logic).

Parameters:
registerPostCommitListeneres - true if post commit listeners will be registered. false for plain listeners.
Method Detail

setMarshallIds

public void setMarshallIds(boolean marshallIds)
Should the listener try and marshall ids for the event listener of post insert. Some Hibernate versions won't put the generated ids in the object that is inserted. Defaults to false.


setPendingCascades

public void setPendingCascades(boolean pendingCascades)
Should the listener try and handle pending cascades avoiding trying to save/update relationships in Compass before they were processed by Hibernate. Default to true.

Note, if set, might cause Compass event processing to be a *tad* slower.


setProcessCollection

public void setProcessCollection(boolean processCollection)
Should the event listener automatically set the processed flag on collections that are created as a result of the marshalling process of Compass. Defaults to true.


injectLifecycle

public void injectLifecycle(SessionFactory sessionFactory,
                            HibernateGpsDevice device)
                     throws HibernateGpsDeviceException
Description copied from interface: HibernateEntityLifecycleInjector
Injects a global lifecycle listener into the concrete SessionFactory implementation.

Specified by:
injectLifecycle in interface HibernateEntityLifecycleInjector
Parameters:
sessionFactory - The SessionFactory to inject the global lifecycle to.
device - The Jpa device calling this injector
Throws:
HibernateGpsDeviceException

removeLifecycle

public void removeLifecycle(SessionFactory sessionFactory,
                            HibernateGpsDevice device)
                     throws HibernateGpsDeviceException
Description copied from interface: HibernateEntityLifecycleInjector
Removes (if possible) lifecycle listeners injected using the inject method.

Specified by:
removeLifecycle in interface HibernateEntityLifecycleInjector
Parameters:
sessionFactory - The SessionFactory to remove lifecycle from
device - The Jpa device calling
Throws:
HibernateGpsDeviceException

doCreateListener

protected Object doCreateListener(HibernateGpsDevice device)


Copyright (c) 2004-2009 The Compass Project.