Make ResultSet.getStatement() return the StatementProxy instead of the delegate.

pull/372/head
Brett Wooldridge 10 years ago
parent a4d1156d08
commit 82536c0fe6

@ -50,7 +50,7 @@ public abstract class PreparedStatementProxy extends StatementProxy implements P
{ {
connection.markCommitStateDirty(); connection.markCommitStateDirty();
ResultSet resultSet = ((PreparedStatement) delegate).executeQuery(); ResultSet resultSet = ((PreparedStatement) delegate).executeQuery();
return ProxyFactory.getProxyResultSet(connection, resultSet); return ProxyFactory.getProxyResultSet(connection, this, resultSet);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */

@ -70,7 +70,7 @@ public final class ProxyFactory
return null; return null;
} }
static ResultSet getProxyResultSet(final ConnectionProxy connection, final ResultSet resultSet) static ResultSet getProxyResultSet(final ConnectionProxy connection, final StatementProxy statement, final ResultSet resultSet)
{ {
// Body is injected by JavassistProxyFactory // Body is injected by JavassistProxyFactory
return null; return null;

@ -18,6 +18,7 @@ package com.zaxxer.hikari.proxy;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Wrapper; import java.sql.Wrapper;
/** /**
@ -28,11 +29,13 @@ import java.sql.Wrapper;
public abstract class ResultSetProxy implements ResultSet public abstract class ResultSetProxy implements ResultSet
{ {
protected final ConnectionProxy connection; protected final ConnectionProxy connection;
protected final StatementProxy statement;
protected final ResultSet delegate; protected final ResultSet delegate;
protected ResultSetProxy(ConnectionProxy connection, ResultSet resultSet) protected ResultSetProxy(ConnectionProxy connection, StatementProxy statement, ResultSet resultSet)
{ {
this.connection = connection; this.connection = connection;
this.statement = statement;
this.delegate = resultSet; this.delegate = resultSet;
} }
@ -55,6 +58,13 @@ public abstract class ResultSetProxy implements ResultSet
// Overridden java.sql.ResultSet Methods // Overridden java.sql.ResultSet Methods
// ********************************************************************** // **********************************************************************
/** {@inheritDoc} */
@Override
public final Statement getStatement() throws SQLException
{
return statement;
}
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void updateRow() throws SQLException public void updateRow() throws SQLException

@ -108,7 +108,7 @@ public abstract class StatementProxy implements Statement
{ {
connection.markCommitStateDirty(); connection.markCommitStateDirty();
ResultSet resultSet = delegate.executeQuery(sql); ResultSet resultSet = delegate.executeQuery(sql);
return ProxyFactory.getProxyResultSet(connection, resultSet); return ProxyFactory.getProxyResultSet(connection, this, resultSet);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@ -212,7 +212,7 @@ public abstract class StatementProxy implements Statement
public ResultSet getResultSet() throws SQLException { public ResultSet getResultSet() throws SQLException {
final ResultSet resultSet = delegate.getResultSet(); final ResultSet resultSet = delegate.getResultSet();
if (resultSet != null) { if (resultSet != null) {
return ProxyFactory.getProxyResultSet(connection, resultSet); return ProxyFactory.getProxyResultSet(connection, this, resultSet);
} }
return null; return null;
} }

Loading…
Cancel
Save