-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Hibernate 3.2 problem with Oracle 10g driver
PostPosted: Fri Apr 20, 2007 5:15 pm 
Newbie

Joined: Fri Apr 20, 2007 5:10 pm
Posts: 2
Location: NY, NY
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?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 21, 2007 9:37 am 
Beginner
Beginner

Joined: Mon May 02, 2005 6:17 pm
Posts: 41
This works. I tested it.

Code:
Connection connection = (Connection)session.connection();
         OracleConnection conn = (OracleConnection)BorrowedConnectionProxy.getWrappedConnection(connection);
         conn.setSessionTimeZone("EST");

_________________
www.globalresearch.ca


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 23, 2007 12:26 pm 
Newbie

Joined: Fri Apr 20, 2007 5:10 pm
Posts: 2
Location: NY, NY
Cool... I'll give that a try.

Thanks for the quick reply!


Top
 Profile  
 
 Post subject: Works in Eclispe but not in JBoss
PostPosted: Mon Apr 23, 2007 4:28 pm 
Newbie

Joined: Mon Apr 23, 2007 4:19 pm
Posts: 1
It works as a junit testcase in Eclispe IDE for JBoss but doesn't work in JBoss Application Servers 4.0.4 or 4.0.5. I've even downloaded the latest Hibernate jar file. I'm getting a ClassCastException...

java.lang.ClassCastException: org.jboss.resource.adapter.jdbc.WrappedConnection

Anyone has it working in JBoss 4.0.4 or 4.0.5?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.