Example usage for org.hibernate Interceptor onPrepareStatement

List of usage examples for org.hibernate Interceptor onPrepareStatement

Introduction

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

Prototype

@Deprecated
String onPrepareStatement(String sql);

Source Link

Document

Called when sql string is being prepared.

Usage

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

License:Open Source License

/**
 * Calls the children's onPrepareStatement, in order, chaining the resultant sql.
 * IE, for two children, does the equlivent of
 * <code>return children[1].onPrepareStatement(children[0].onPrepareStatement(arg0));</code>
 *
 * @param sql original sql// w  w w . j  a  v  a2  s. c  o  m
 * @return modified sql
 */
@SuppressWarnings("PMD.UseStringBufferForStringAppends") // PMD incorrectly thinks we're doing concat here
public String onPrepareStatement(String sql) {
    String result = sql;
    for (Interceptor i : children) {
        result = i.onPrepareStatement(result);
    }
    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  v a2 s .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 String onPrepareStatement(String sql) {
    String result = null;// w  ww  .  ja  v a  2  s .c om
    for (Interceptor element : interceptors) {
        result = element.onPrepareStatement(sql);
        if (result != null) {
            /*
             * If any interceptor has returned something not null, stop the
             * chain
             */
            break;
        }
    }
    return result;

}

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

License:Apache License

public String onPrepareStatement(String sql) {
    for (Object o : interceptors.entrySet()) {
        Map.Entry entry = (Map.Entry) o;
        Interceptor interceptor = (Interceptor) entry.getValue();
        sql = interceptor.onPrepareStatement(sql);
    }/*w ww.  j  av a 2  s . c om*/

    return sql;
}

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

License:Open Source License

public String onPrepareStatement(HibernateInterceptorChain chain, Interceptor target, String sql) {
    return target.onPrepareStatement(sql);
}

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

License:Mozilla Public License

public String onPrepareStatement(String sql) {
    for (Interceptor i : interceptors) {
        sql = i.onPrepareStatement(sql);
    }/*from  www.j ava2s . c  o  m*/

    return sql;
}

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

License:Apache License

public String onPrepareStatement(String sql) {
    for (Interceptor interceptor : interceptors) {
        sql = interceptor.onPrepareStatement(sql);
    }/*from   w w  w  . j a v a2  s.c  om*/
    return sql;
}