com.taggercat
Class MultiTenantInterceptor

java.lang.Object
  extended by org.hibernate.EmptyInterceptor
      extended by com.taggercat.MultiTenantInterceptor
All Implemented Interfaces:
java.io.Serializable, org.hibernate.Interceptor

public class MultiTenantInterceptor
extends org.hibernate.EmptyInterceptor

This interceptor is used to assign the current tenant name in multi-tenant objects. We were unable to use a Hibernate save listener since Hibernate assigns modification in the listener in a separate update statement after the insert. That functionality breaks database trigger code that relies on the tenant name with the initial insert.

See Also:
Serialized Form
 

Field Summary
 
Fields inherited from class org.hibernate.EmptyInterceptor
INSTANCE
 
Constructor Summary
MultiTenantInterceptor()
           
 
Method Summary
 java.lang.String getTenantName()
           
 boolean onSave(java.lang.Object entity, java.io.Serializable id, java.lang.Object[] state, java.lang.String[] propertyNames, org.hibernate.type.Type[] types)
           
 void setTenantName(java.lang.String tenantName)
           
 
Methods inherited from class org.hibernate.EmptyInterceptor
afterTransactionBegin, afterTransactionCompletion, beforeTransactionCompletion, findDirty, getEntity, getEntityName, instantiate, isTransient, onCollectionRecreate, onCollectionRemove, onCollectionUpdate, onDelete, onFlushDirty, onLoad, onPrepareStatement, postFlush, preFlush
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiTenantInterceptor

public MultiTenantInterceptor()
Method Detail

onSave

public boolean onSave(java.lang.Object entity,
                      java.io.Serializable id,
                      java.lang.Object[] state,
                      java.lang.String[] propertyNames,
                      org.hibernate.type.Type[] types)
Specified by:
onSave in interface org.hibernate.Interceptor
Overrides:
onSave in class org.hibernate.EmptyInterceptor

getTenantName

public java.lang.String getTenantName()
Returns:
the tenantName

setTenantName

public void setTenantName(java.lang.String tenantName)
Parameters:
tenantName - the tenantName to set