@Override public SqlStatementCustomizer createForType(Annotation annotation, final Class sqlObjectType) { return new SqlStatementCustomizer() { @Override public void apply(SQLStatement sqlStatement) throws SQLException { sqlStatement.addStatementCustomizer(new StatementCustomizer() { @Override public void beforeExecution(PreparedStatement stmt, StatementContext ctx) throws SQLException { System.out.println(stmt.toString()); } @Override public void afterExecution(PreparedStatement stmt, StatementContext ctx) throws SQLException { } @Override public void cleanup(StatementContext ctx) throws SQLException { } }); } }; }
public void apply(SQLStatement q) throws SQLException { q.addStatementCustomizer(new StatementCustomizers.FetchDirectionStatementCustomizer(direction)); } }
/** * Set the query timeout, in seconds, on the prepared statement * * @param seconds number of seconds before timing out * * @return the same instance */ public SelfType setQueryTimeout(final int seconds) { return addStatementCustomizer(new StatementCustomizers.QueryTimeoutCustomizer(seconds)); }
public void setFetchDirection(final int value) { addStatementCustomizer(new StatementCustomizers.FetchDirectionStatementCustomizer(value)); }
public void setFetchDirection(final int value) { addStatementCustomizer(new StatementCustomizers.FetchDirectionStatementCustomizer(value)); }
@Override public void apply(SQLStatement q) throws SQLException { q.addStatementCustomizer(new StatementCustomizers.FetchDirectionStatementCustomizer(direction)); } }
/** * Set the query timeout, in seconds, on the prepared statement * * @param seconds number of seconds before timing out * * @return the same instance */ public SelfType setQueryTimeout(final int seconds) { return addStatementCustomizer(new StatementCustomizers.QueryTimeoutCustomizer(seconds)); }
public void apply(SQLStatement q) throws SQLException { final int initial_level = q.getContext().getConnection().getTransactionIsolation(); q.addStatementCustomizer(new BaseStatementCustomizer() { @Override public void beforeExecution(PreparedStatement stmt, StatementContext ctx) throws SQLException { setTxnIsolation(ctx, level.intValue()); } @Override public void afterExecution(PreparedStatement stmt, StatementContext ctx) throws SQLException { setTxnIsolation(ctx, initial_level); } private void setTxnIsolation(StatementContext ctx, int level) throws SQLException { final Connection c = ctx.getConnection(); if (c.getTransactionIsolation() != level) { c.setTransactionIsolation(level); } } }); } }
@Override public void apply(SQLStatement q) throws SQLException { final int initial_level = q.getContext().getConnection().getTransactionIsolation(); q.addStatementCustomizer(new BaseStatementCustomizer() { @Override public void beforeExecution(PreparedStatement stmt, StatementContext ctx) throws SQLException { setTxnIsolation(ctx, level.intValue()); } @Override public void afterExecution(PreparedStatement stmt, StatementContext ctx) throws SQLException { setTxnIsolation(ctx, initial_level); } private void setTxnIsolation(StatementContext ctx, int level) throws SQLException { final Connection c = ctx.getConnection(); if (c.getTransactionIsolation() != level) { c.setTransactionIsolation(level); } } }); } }