results.put(returnParameter, create(attachable).select(field).fetchOne(field));
return 0;
}
private final int executeCallableStatement() {
Configuration configuration = attachable.getConfiguration();
ExecuteContext ctx = new DefaultExecuteContext(configuration, this);
ExecuteListener listener = new ExecuteListeners(ctx);
try {
Connection connection = configuration.getConnection();
listener.renderStart(ctx);
ctx.sql(create(configuration).render(this));
listener.renderEnd(ctx);
listener.prepareStart(ctx);
ctx.statement(connection.prepareCall(ctx.sql()));
listener.prepareEnd(ctx);
listener.bindStart(ctx);
create(configuration).bind(this, ctx.statement());
registerOutParameters(configuration, (CallableStatement) ctx.statement());
listener.bindEnd(ctx);
// Postgres requires two separate queries running in the same
// transaction to be executed when fetching refcursor types
boolean autoCommit = connection.getAutoCommit();
if (autoCommit && configuration.getDialect() == SQLDialect.POSTGRES) {
connection.setAutoCommit(false);
}
listener.executeStart(ctx);
ctx.statement().execute();
listener.executeEnd(ctx);
if (autoCommit && configuration.getDialect() == SQLDialect.POSTGRES) {
connection.setAutoCommit(autoCommit);
}
fetchOutParameters(ctx);
return 0;