Example usage for org.hibernate Interceptor isTransient

List of usage examples for org.hibernate Interceptor isTransient

Introduction

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

Prototype

Boolean isTransient(Object entity);

Source Link

Document

Called to distinguish between transient and detached entities.

Usage

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 Boolean is the result of this method, and <em>the remaining
 * children's isTransient methods will not be called.</em>
 *
 * @param entity entity/*from   w w w  . j  a  v  a2  s.  c  o m*/
 * @return isTransient result from first child to return non-null, or null if all children return null
 */
public Boolean isTransient(Object entity) {
    for (Interceptor i : children) {
        Boolean tmp = i.isTransient(entity);
        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);//from   ww w .ja  va  2 s  . c  om
    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 Boolean isTransient(Object entity) {
    Boolean result = null;/*from w  w  w . j  a v a2 s.co m*/
    for (Interceptor element : interceptors) {
        result = element.isTransient(entity);
        if (result != null) {
            // If any interceptor has returned either true or false,
            // stop the chain
            break;
        }
    }
    return result;
}

From source file:org.chenillekit.hibernate.interceptors.ChainedInterceptor.java

License:Apache License

public Boolean isTransient(Object entity) {
    boolean result = false;
    for (Object o : interceptors.entrySet()) {
        Map.Entry entry = (Map.Entry) o;
        Interceptor interceptor = (Interceptor) entry.getValue();
        if (interceptor.isTransient(entity))
            result = true;/*w w  w .  j av  a  2 s .  c  o m*/
    }
    return result;
}

From source file:org.hyperic.hibernate.DefaultInterceptorChain.java

License:Open Source License

public Boolean isTransient(HibernateInterceptorChain chain, Interceptor target, Object entity) {
    return target.isTransient(entity);
}

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

License:Mozilla Public License

public Boolean isTransient(Object entity) {
    Boolean returnValue = null; // by default let hibernate figure it out

    for (Interceptor i : interceptors) {
        Boolean tmpReturnValue = i.isTransient(entity);

        // //from  www  .j a  v  a 2 s.  c  o  m
        if (tmpReturnValue != null) {
            if (returnValue == null) {
                returnValue = tmpReturnValue;
            } else {
                returnValue = returnValue && tmpReturnValue;
            }
        }
    }

    return returnValue;
}

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

License:Apache License

public Boolean isTransient(Object entity) {
    Boolean result = null;/* w  ww.  j av a 2  s.com*/
    for (Interceptor interceptor : interceptors) {
        result = interceptor.isTransient(entity);
        if (result != null) {
            break;
        }
    }
    return result;
}