Example usage for org.hibernate Interceptor getEntity

List of usage examples for org.hibernate Interceptor getEntity

Introduction

In this page you can find the example usage for org.hibernate Interceptor getEntity.

Prototype

Object getEntity(String entityName, Serializable id) throws CallbackException;

Source Link

Document

Get a fully loaded entity instance that is cached externally.

Usage

From source file:com.fiveamsolutions.nci.commons.util.CompositeInterceptorTest.java

License:Open Source License

private void helper(Interceptor i, boolean expectChanges) {
    i.afterTransactionBegin(null);/*from   w w w .  ja  v  a 2s .c  o m*/
    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 getEntity(String entityName, Serializable id) {
    Object result = null;//from   ww  w  .j ava2 s .c  o m
    for (Interceptor element : interceptors) {
        result = element.getEntity(entityName, 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 getEntity(HibernateInterceptorChain chain, Interceptor target, String entityName,
        Serializable id) {/*from  ww  w .j  ava2s. c  om*/
    return target.getEntity(entityName, id);
}

From source file:org.openmrs.api.db.hibernate.ChainingInterceptor.java

License:Mozilla Public License

public Object getEntity(String entityName, Serializable id) {
    for (Interceptor i : interceptors) {
        Object o = i.getEntity(entityName, id);
        if (o != null) {
            return o;
        }//from  w w  w  .  ja v a2 s. c o  m
    }

    return null;
}

From source file:org.riotfamily.common.hibernate.ChainedInterceptor.java

License:Apache License

public Object getEntity(String entityName, Serializable id) throws CallbackException {

    for (Interceptor interceptor : interceptors) {
        Object result = interceptor.getEntity(entityName, id);
        if (result != null) {
            return result;
        }// ww w  .  j a v a2s  .c  o  m
    }
    return null;
}