org.compass.gps.device.hibernate
Class CompassTransactionInterceptor

java.lang.Object
  extended by org.compass.gps.device.hibernate.CompassTransactionInterceptor
All Implemented Interfaces:
Interceptor

public class CompassTransactionInterceptor
extends Object
implements Interceptor

A Compass Hibernate interceptor to manage Compass transactions based on Hibernate Interceptor transaction lifecycle callbacks. Useful when working with Compass Local transactions and Hibernate JDBC transaction manager.

In order to use this interceptor call injectInterceptor(org.hibernate.SessionFactory, CompassTransactionInterceptor) using the SessionFactory and an instance of this class.

For another option of integrating Compass transactions and Hibernate, please see JTASyncTransactionFactory, XATransactionFactory or HibernateSyncTransactionFactory.

Author:
kimchy

Constructor Summary
CompassTransactionInterceptor(Compass compass)
           
CompassTransactionInterceptor(Compass compass, boolean commitBeforeTransactionCompletion, Interceptor interceptor)
           
 
Method Summary
 void afterTransactionBegin(Transaction transaction)
           
 void afterTransactionCompletion(Transaction transaction)
           
 void beforeTransactionCompletion(Transaction transaction)
           
 int[] findDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types)
           
 Object getEntity(String entityName, Serializable id)
           
 String getEntityName(Object object)
           
static void injectInterceptor(SessionFactory sessionFactory, CompassTransactionInterceptor interceptor)
           
 Object instantiate(String entityName, EntityMode entityMode, Serializable id)
           
 Boolean isTransient(Object entity)
           
 void onCollectionRecreate(Object collection, Serializable key)
           
 void onCollectionRemove(Object collection, Serializable key)
           
 void onCollectionUpdate(Object collection, Serializable key)
           
 void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)
           
 boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types)
           
 boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)
           
 String onPrepareStatement(String sql)
           
 boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)
           
 void postFlush(Iterator entities)
           
 void preFlush(Iterator entities)
           
(package private)  void setInterceptor(Interceptor interceptor)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompassTransactionInterceptor

public CompassTransactionInterceptor(Compass compass)

CompassTransactionInterceptor

public CompassTransactionInterceptor(Compass compass,
                                     boolean commitBeforeTransactionCompletion,
                                     Interceptor interceptor)
Method Detail

injectInterceptor

public static void injectInterceptor(SessionFactory sessionFactory,
                                     CompassTransactionInterceptor interceptor)
                              throws Exception
Throws:
Exception

setInterceptor

void setInterceptor(Interceptor interceptor)

afterTransactionBegin

public void afterTransactionBegin(Transaction transaction)
Specified by:
afterTransactionBegin in interface Interceptor

beforeTransactionCompletion

public void beforeTransactionCompletion(Transaction transaction)
Specified by:
beforeTransactionCompletion in interface Interceptor

afterTransactionCompletion

public void afterTransactionCompletion(Transaction transaction)
Specified by:
afterTransactionCompletion in interface Interceptor

onDelete

public void onDelete(Object entity,
                     Serializable id,
                     Object[] state,
                     String[] propertyNames,
                     Type[] types)
Specified by:
onDelete in interface Interceptor

onFlushDirty

public boolean onFlushDirty(Object entity,
                            Serializable id,
                            Object[] currentState,
                            Object[] previousState,
                            String[] propertyNames,
                            Type[] types)
Specified by:
onFlushDirty in interface Interceptor

onLoad

public boolean onLoad(Object entity,
                      Serializable id,
                      Object[] state,
                      String[] propertyNames,
                      Type[] types)
Specified by:
onLoad in interface Interceptor

onSave

public boolean onSave(Object entity,
                      Serializable id,
                      Object[] state,
                      String[] propertyNames,
                      Type[] types)
Specified by:
onSave in interface Interceptor

postFlush

public void postFlush(Iterator entities)
Specified by:
postFlush in interface Interceptor

preFlush

public void preFlush(Iterator entities)
Specified by:
preFlush in interface Interceptor

isTransient

public Boolean isTransient(Object entity)
Specified by:
isTransient in interface Interceptor

instantiate

public Object instantiate(String entityName,
                          EntityMode entityMode,
                          Serializable id)
Specified by:
instantiate in interface Interceptor

findDirty

public int[] findDirty(Object entity,
                       Serializable id,
                       Object[] currentState,
                       Object[] previousState,
                       String[] propertyNames,
                       Type[] types)
Specified by:
findDirty in interface Interceptor

getEntityName

public String getEntityName(Object object)
Specified by:
getEntityName in interface Interceptor

getEntity

public Object getEntity(String entityName,
                        Serializable id)
Specified by:
getEntity in interface Interceptor

onPrepareStatement

public String onPrepareStatement(String sql)
Specified by:
onPrepareStatement in interface Interceptor

onCollectionRemove

public void onCollectionRemove(Object collection,
                               Serializable key)
                        throws CallbackException
Specified by:
onCollectionRemove in interface Interceptor
Throws:
CallbackException

onCollectionRecreate

public void onCollectionRecreate(Object collection,
                                 Serializable key)
                          throws CallbackException
Specified by:
onCollectionRecreate in interface Interceptor
Throws:
CallbackException

onCollectionUpdate

public void onCollectionUpdate(Object collection,
                               Serializable key)
                        throws CallbackException
Specified by:
onCollectionUpdate in interface Interceptor
Throws:
CallbackException


Copyright (c) 2004-2009 The Compass Project.