Guys:
We're using Hibernate with Oracle 10g. In our schema, we have Timestamp data types using "with time zone" and "with local time zone" modifiers. This requires Oracle to know what the session time zone is, which it seem to do via the driver. In Oracle's driver, the OracleConnection object has a setSessionTimeZone method that does this.
In Hibernate 3.0.2, we would use the following code to set the time zone in the driver:
Code:
OracleConnection thisConnection = (OracleConnection) thisSession.connection();
thisConnection.setSessionTimeZone("EST");
THis sucks, but Oracle has no other way of doing it, and not doing it causes the driver to throw exceptions complaining that the session time zone is not set. So there is no other choice.
However, the foregoing no longer works in 3.2.X. Seems that Session.connection() returns a proxy of some sort, and that the cast throws a ClassCastException. What is wierder still is that the Eclipse debugger says the type of the object is Oracle's LogicalConnection object, which is what we would expect. All we can tell is that the object returned is named $Proxy0 and casting it to ANYTHING driver specific causes a cast exception.
The Javadoc on Session ways it returns a Connection object, and mentions nothing about proxies.
So, we stuck. How can we get the underlying Oracle connection so we can set the time zone as we must?