-->
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: Using Oracle objects with Hibernate
PostPosted: Fri Jun 22, 2007 10:46 am 
Newbie

Joined: Mon Aug 21, 2006 3:47 pm
Posts: 4
Hi,

I am involved in a legacy web application re-write project using Hibernate. I'm using the following configuration in my new web based application which is based on Hibernate.

JBoss 4 server
Spring 2
Hibernate 3.2.4.GA
Oracle 10g database (10.2.0.2.0)
JDK 1.5

I have some database packages in Oracle which accept Oracle objects as input parameters and return data. The code in my old application is plain JDBC code and is NOT using hibernate. I need to get it working using Hibernate

That JDBC code makes use of the following Oracle objects and pass on an instance of java.sql.array to a database package. The other Oracle object types involved are

oracle.sql.StructDescriptor
oracle.sql.STRUCT
oracle.sql.ArrayDescriptor
oracle.sql.Array

1. Does any one know how to create these objects using Hibernate ? Or how can we work with these objects using Hibernate ?

2. Can we get access to a java.sql.connection object using hibernate ? Most of the constructors for creating the Oracle objects mentioned above take in a parameter of type java.sql.Connection.

Thanks in Advance.


Top
 Profile  
 
 Post subject: Re: Oracle Objects
PostPosted: Mon Jun 25, 2007 11:45 am 
Newbie

Joined: Mon Aug 21, 2006 3:47 pm
Posts: 4
I got the code to working by obtaining a connection from the session.connection() method (which is deprecated for some reason).

I have a new problem now:

I have the following line in my code which creates an instance of oracle.sql.StructDescriptor class as follows


StructDescriptor.createDescriptor("someSqlObject", session.connection());


Where session is my org.hibernate.Session object.

I've worked with connection objects before and managed to invoke a database procedure successfully using the connection that session.connection() method provides to me.

However it looks like the StructDescriptor.createDescriptor(...) call is type casting the instance of connection object to oracle.jdbc.OracleConnection. I'm getting a ClassCastException when this happens. I'm using Spring so I might be getting a proxy for the connection object but that connection object does work when executing other prepared statements and callable statements.


So I have 2 questions:

1. Why can't we cast connection retrieved from session.connection() method to oracle.jdbc.OracleConnection ? Is there a work around to the ClassCastException error ?


2. Why is the session.connection() method deprecated ? Is there any alternate that we can use ?


Top
 Profile  
 
 Post subject: Re: Oracle Objects
PostPosted: Tue Jun 26, 2007 3:38 pm 
Newbie

Joined: Mon Aug 21, 2006 3:47 pm
Posts: 4
Managed to solve the first problem by making use of


java.sql.Connection con =
org.hibernate.jdbc.BorrowedConnectionProxy.getWrappedConnection(session.connection());


Once I had an instance of java.sql.Connection, I was able to cast it to oracle.jdbc.OracleConnection


Still not sure why the session.connection() method is deprecated.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 26, 2007 8:11 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
it is deprecated as a warning. Next version (3.3 definately 4.0) the replacement approach will be in place.


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.