[hibernate-dev] Connection proxying
Steve Ebersole
steve.ebersole at jboss.com
Tue Aug 29 11:08:37 EDT 2006
This is in regards to the JDBC interaction code I recently committed
into the sandbox in SVN.
I am considering proxying the JDBC connections specifically for the
purpose of auto-registering "subordinate objects" (result sets and
statements) for automatic cleanup. Currently the registration is a
manual process in order to take advantage of the automatic cleanup (have
a look at org.hibernate.jdbc4.jdbc.impl.BasicWorkTest for the basic
usage pattern). Specifically what I am thinking is taking a page from
how app servers implement Connection handles in relation to data
sources:
public interface HibernateConnection extends java.sql.Connection {
public Connection getWrappedConnection();
}
Of course this makes it more difficult for anyone depending on casting
to a particular driver's Connection impl at some point. But,
considering that this is atypical usage, my thought was to treat it as
the more complex use-case; and since this generally requires casting
anyway, one extra cast and "extraction" is not that big of a deal to me.
For example, to get an oracle connection (for LOB handling for example):
( ( OracleConnection ) connection ).doSomethingOracleSpecific() -> ( (
OracleConnection ) ( ( HibernateConnection ) connection
).getWrappedConnection() ).doSomethingOracleSpecific()
Plus, would potentially allow for some other niceties like automatic
statement logging (perhaps even with parameter replacement).
Thoughts?
More information about the hibernate-dev
mailing list