Announcement Announcement Module
Collapse
No announcement yet.
Working with Oracle Objects Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Working with Oracle Objects

    Hi,

    I'm working on an application which has the following configuration

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


    I want to invoke a procedure that takes in an array of Oracle objects. To do this I need to create instances of the following objects

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

    I am trying to create the StructDescriptor object using the connection obtained from hibernate (session.connection() method) but getting a ClassCastException as the call to create a StructDescriptor object seems to be type casting the connection to oracle.jdbc.OracleConnection


    Specifically 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.

    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 alternative that we can use ?

    I'm not sure if this is a problem with hibernate or it's because Spring is giving me a RunTime proxy connection object when I ask for it.

    I end up getting the following error
    java.lang.ClassCastException: $Proxy35

    Thanks in advance.

  • #2
    Re: Oracle objects

    Managed to solve the first problem by making use of


    java.sql.Connection con =
    org.hibernate.jdbc.BorrowedConnectionProxy.getWrap pedConnection(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.

    Comment

    Working...
    X