It usually make sense to leverage Hibernateâ€™s DriverManagerConnectionProvider when working with a DataSource configured via config files and accessible via JNDI.
But the problem is that the JBoss implementation of the DataSource mechanism ... wraps the Connection objects in a Wrapper (WrappedConnection.java) every time.
It is possible to get at the underlying connection by casting the Connection object to WrappedConnection and then invoking the getUnderlyingConnection() method. This is great as it allows Connection objects to be identified as they come & go to the pool over and over. BUT isn't there a cleaner way to do this?
In Java 1.6, the Connection interface extends the Wrapper interface which requires the implementation of a unwrap() method, that seems a lot more generic but I'm not sure which version of JBoss is up to date with Java 6 in order to allow its user to do that... any comments?