List of usage examples for org.hibernate Interceptor instantiate
Object instantiate(String entityName, EntityMode entityMode, Serializable id) throws CallbackException;
From source file:com.fiveamsolutions.nci.commons.util.CompositeInterceptor.java
License:Open Source License
/** * Calls the children, in order, looking for the first non-null return value. If a non * null value is returned, that object is the result of this method, and <em>the remaining * children's instantiate methods will not be called.</em> * * @param entityName entityName// w w w .ja v a 2 s. c o m * @param entityMode entityMode * @param id id * @return instance from first child to return non-null, or null if all children return null */ public Object instantiate(String entityName, EntityMode entityMode, Serializable id) { for (Interceptor i : children) { Object tmp = i.instantiate(entityName, entityMode, id); if (tmp != null) { return tmp; } } return null; }
From source file:com.fiveamsolutions.nci.commons.util.CompositeInterceptorTest.java
License:Open Source License
private void helper(Interceptor i, boolean expectChanges) { i.afterTransactionBegin(null);// w w w .j a v a 2s. com i.afterTransactionCompletion(null); i.beforeTransactionCompletion(null); assertNull(i.getEntity(null, null)); assertNull(i.getEntityName(null)); if (expectChanges) { assertNotNull(i.findDirty(null, null, null, null, null, null)); assertNotNull(i.instantiate(null, null, null)); assertNotNull(i.isTransient(null)); assertTrue(!"foo".equals(i.onPrepareStatement("foo"))); } else { assertNull(i.findDirty(null, null, null, null, null, null)); assertNull(i.instantiate(null, null, null)); assertNull(i.isTransient(null)); assertEquals("foo", i.onPrepareStatement("foo")); } i.onCollectionRecreate(null, null); i.onCollectionRemove(null, null); i.onCollectionUpdate(null, null); i.onDelete(null, null, null, null, null); assertEquals(expectChanges, i.onFlushDirty(null, null, null, null, null, null)); assertEquals(expectChanges, i.onLoad(null, null, null, null, null)); assertEquals(expectChanges, i.onSave(null, null, null, null, null)); i.postFlush(null); i.preFlush(null); }
From source file:gov.nih.nci.cabig.ctms.audit.ChainedInterceptor.java
License:BSD License
public Object instantiate(String entityName, EntityMode entityMode, Serializable id) { Object result = null;//from w w w . j ava2s . c om for (Interceptor element : interceptors) { result = element.instantiate(entityName, entityMode, id); if (result != null) { /* * If any interceptor has returned something not null, stop the * chain */ break; } } return result; }
From source file:org.hyperic.hibernate.DefaultInterceptorChain.java
License:Open Source License
public Object instantiate(HibernateInterceptorChain chain, Interceptor target, String entityName, EntityMode entityMode, Serializable id) { return target.instantiate(entityName, entityMode, id); }
From source file:org.openmrs.api.db.hibernate.ChainingInterceptor.java
License:Mozilla Public License
public Object instantiate(String entityName, EntityMode entityMode, Serializable id) { for (Interceptor i : interceptors) { Object o = i.instantiate(entityName, entityMode, id); if (o != null) { return o; }//from w w w .j a va2 s . c o m } return null; }
From source file:org.riotfamily.common.hibernate.ChainedInterceptor.java
License:Apache License
public Object instantiate(String entityName, EntityMode entityMode, Serializable id) throws CallbackException { for (Interceptor interceptor : interceptors) { Object result = interceptor.instantiate(entityName, entityMode, id); if (result != null) { return result; }/*from ww w . ja va 2 s. c om*/ } return null; }