We need the connection during the binding step for Postgres array machinations.

This commit is contained in:
Michael Bayne
2009-04-27 18:06:55 +00:00
parent 1468275c18
commit d2e1ea6eda
2 changed files with 7 additions and 4 deletions
@@ -21,6 +21,7 @@
package com.samskivert.depot.impl; package com.samskivert.depot.impl;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -731,14 +732,15 @@ public abstract class BuildVisitor implements ExpressionVisitor<Void>
protected static interface Bindable protected static interface Bindable
{ {
void doBind (PreparedStatement stmt, int argIx) throws Exception; void doBind (Connection conn, PreparedStatement stmt, int argIx) throws Exception;
} }
protected static Bindable newBindable ( protected static Bindable newBindable (
final DepotMarshaller<?> marshaller, final String field, final Object pojo) final DepotMarshaller<?> marshaller, final String field, final Object pojo)
{ {
return new Bindable() { return new Bindable() {
public void doBind (PreparedStatement stmt, int argIx) throws Exception { public void doBind (Connection conn, PreparedStatement stmt, int argIx)
throws Exception {
marshaller.getFieldMarshaller(field).getAndWriteToStatement(stmt, argIx, pojo); marshaller.getFieldMarshaller(field).getAndWriteToStatement(stmt, argIx, pojo);
} }
}; };
@@ -747,7 +749,8 @@ public abstract class BuildVisitor implements ExpressionVisitor<Void>
protected static Bindable newBindable (final Object value) protected static Bindable newBindable (final Object value)
{ {
return new Bindable() { return new Bindable() {
public void doBind (PreparedStatement stmt, int argIx) throws Exception { public void doBind (Connection conn, PreparedStatement stmt, int argIx)
throws Exception {
// TODO: how can we abstract this fieldless marshalling // TODO: how can we abstract this fieldless marshalling
if (value instanceof ByteEnum) { if (value instanceof ByteEnum) {
// byte enums require special conversion // byte enums require special conversion
@@ -83,7 +83,7 @@ public abstract class SQLBuilder
int argIx = 1; int argIx = 1;
for (BuildVisitor.Bindable bindable : _buildVisitor.getBindables()) { for (BuildVisitor.Bindable bindable : _buildVisitor.getBindables()) {
try { try {
bindable.doBind(stmt, argIx); bindable.doBind(conn, stmt, argIx);
} catch (Exception e) { } catch (Exception e) {
log.warning("Failed to bind statement argument", "argIx", argIx); log.warning("Failed to bind statement argument", "argIx", argIx);
} }