Example usage for org.hibernate Interceptor onFlushDirty

List of usage examples for org.hibernate Interceptor onFlushDirty

Introduction

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

Prototype

boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState,
        String[] propertyNames, Type[] types) throws CallbackException;

Source Link

Document

Called when an object is detected to be dirty, during a flush.

Usage

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

License:Open Source License

/**
 * Calls the children's onFlushDirty methods, in order.
 *
 * @param entity entity/*from   w  w w .  j ava  2 s.c om*/
 * @param id id
 * @param currentState currentState
 * @param previousState previousState
 * @param propertyNames propertyNames
 * @param types types
 *
 * @return true if <em>any</em> child has modified the state in any way
 */
public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState,
        String[] propertyNames, Type[] types) {
    boolean result = false;
    for (Interceptor i : children) {
        result |= i.onFlushDirty(entity, id, currentState, previousState, propertyNames, types);
    }

    return result;
}

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  va2  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:debop4k.data.orm.hibernate.interceptors.MultipleInterceptor.java

License:Apache License

@Override
public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState,
        String[] propertyNames, Type[] types) {
    if (nonEmpty()) {
        for (Interceptor interceptor : interceptors) {
            interceptor.onFlushDirty(entity, id, currentState, previousState, propertyNames, types);
        }/* w ww. jav a2  s.c  om*/
    }
    return false;
}

From source file:gov.nih.nci.cabig.ctms.audit.ChainedInterceptor.java

License:BSD License

public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState,
        String[] propertyNames, Type[] types) throws CallbackException {
    boolean result = false;
    for (Interceptor element : interceptors) {
        if (element.onFlushDirty(entity, id, currentState, previousState, propertyNames, types)) {
            /*//from   w w  w. j ava 2 s.co m
             * Returns true if one interceptor in the chain has modified the
             * object current state result = true;
             */
        }
    }
    return result;
}

From source file:io.github.jonestimd.hibernate.InterceptorChain.java

License:Open Source License

@Override
public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState,
        String[] propertyNames, Type[] types) throws CallbackException {
    boolean modified = false;
    for (Interceptor interceptor : chain) {
        modified |= interceptor.onFlushDirty(entity, id, currentState, previousState, propertyNames, types);
    }/*  w  w  w .  ja  v  a2  s  .c  om*/
    return modified;
}

From source file:kr.debop4j.data.hibernate.interceptor.MultiInterceptor.java

License:Apache License

@Override
public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState,
        String[] propertyNames, Type[] types) {
    if (!isExists())
        return false;

    if (isTraceEnabled)
        log.trace("?? onFlush  ? .");

    for (final Interceptor interceptor : interceptors) {
        interceptor.onFlushDirty(entity, id, currentState, previousState, propertyNames, types);
    }//  w ww . j  a v  a  2s.co  m

    return false;
}

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

License:Apache License

/**
 * Called before a flush/*from w ww.ja va  2  s  .  c  om*/
 */
public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState,
        String[] propertyNames, Type[] types) {
    boolean result = false;
    for (Object o : interceptors.entrySet()) {
        Map.Entry entry = (Map.Entry) o;
        Interceptor interceptor = (Interceptor) entry.getValue();
        if (interceptor.onFlushDirty(entity, id, currentState, previousState, propertyNames, types))
            result = true;
    }
    return result;
}

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

License:Open Source License

public boolean onFlushDirty(HibernateInterceptorChain chain, Interceptor target, Object entity, Serializable id,
        Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) {
    return target.onFlushDirty(entity, id, currentState, previousState, propertyNames, types);
}

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

License:Mozilla Public License

public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState,
        String[] propertyNames, Type[] types) {
    boolean objectChanged = false;

    for (Interceptor i : interceptors) {
        // must be in this order so that java doesn't skip the method call for optimizations
        objectChanged = i.onFlushDirty(entity, id, currentState, previousState, propertyNames, types)
                || objectChanged;/*from   w  w w.j  av a2s.c om*/
    }

    return objectChanged;
}

From source file:org.osaf.cosmo.hibernate.CompoundInterceptor.java

License:Apache License

@Override
public boolean onFlushDirty(Object object, Serializable id, Object[] currentState, Object[] previousState,
        String[] propertyNames, Type[] types) {
    boolean modified = false;
    for (Interceptor i : interceptors)
        modified = i.onFlushDirty(object, id, currentState, previousState, propertyNames, types);

    return modified;
}