This is a follow-up to Executing native query with Hibernate 4.1
I\'ve tried the options in the listed answer but we get errors and are unable to unwrap the proxied
Option 2 code works correctly.
ie.
OracleConnection oracleConnection = connection.unwrap( OracleConnection.class );
The problem was we had 2 versions of ojbc.jar - one as a Jboss module and one within the EAR, hence the ClassCastException.
As mentioned in the comments, this code also works
oracle.jdbc.driver.OracleConnection oc = (oracle.jdbc.driver.OracleConnection) connection.getMetaData().getConnection();