improve java.sql.Wrapper support

This commit is contained in:
wenshao
2012-12-19 14:58:23 +08:00
parent ce9c120dbe
commit 2a028bdc05
28 changed files with 1203 additions and 125 deletions
@@ -375,10 +375,10 @@ public class ConnectionProxyImpl extends WrapperProxyImpl implements ConnectionP
@SuppressWarnings("unchecked")
public <T> T unwrap(Class<T> iface) throws SQLException {
if (iface == Connection.class) {
return (T) connection;
if (iface == this.getClass() || iface == ConnectionProxy.class) {
return (T) this;
}
return super.unwrap(iface);
}
@@ -473,13 +473,4 @@ public class PreparedStatementProxyImpl extends StatementProxyImpl implements Pr
public String getLastExecuteSql() {
return this.sql;
}
@SuppressWarnings("unchecked")
public <T> T unwrap(Class<T> iface) throws SQLException {
if (iface == PreparedStatement.class) {
return (T) statement;
}
return super.unwrap(iface);
}
}
@@ -1071,15 +1071,6 @@ public class ResultSetProxyImpl extends WrapperProxyImpl implements ResultSetPro
throw new SQLFeatureNotSupportedException();
}
@SuppressWarnings("unchecked")
public <T> T unwrap(Class<T> iface) throws SQLException {
if (iface == ResultSet.class) {
return (T) resultSet;
}
return super.unwrap(iface);
}
public int getCloseCount() {
return closeCount;
}
@@ -393,15 +393,6 @@ public class StatementProxyImpl extends WrapperProxyImpl implements StatementPro
throw new SQLFeatureNotSupportedException();
}
@SuppressWarnings("unchecked")
public <T> T unwrap(Class<T> iface) throws SQLException {
if (iface == Statement.class) {
return (T) statement;
}
return super.unwrap(iface);
}
@Override
public Map<Integer, JdbcParameter> getParameters() {
return Collections.emptyMap();
@@ -54,7 +54,7 @@ public abstract class WrapperProxyImpl implements WrapperProxy {
return false;
}
if (iface.isInstance(this)) {
if (iface == this.getClass()) {
return true;
}
@@ -67,8 +67,8 @@ public abstract class WrapperProxyImpl implements WrapperProxy {
if (iface == null) {
return null;
}
if (iface.isInstance(this)) {
if (iface == this.getClass()) {
return (T) this;
}