Monday, September 20, 2010

Pass Collection of Objects with Attributes to a Stored Procedure using iBatis

In my last entry I had a requirement which needed to pass a List to an Oracle Stored Procedure, well, that thing is history.
But now the problem becomes more complex, because, what happen if I'm expecting on my Stored Proc and Type (STRUCT)
This is my Collection in Oracle!
And this is my Stored Proc (this is just a sample which receives the TABLE of Records)
This is the table where I'm going to INSERT
Obviously, the solution is Create a Handler like I did on my last entry, but is not going to be as simple, because I need to Map my Oracle STRUCT with my Java Code, so I have to do an domain object (POJO) coupled to Oracle and my Handler.
Once we have our Mapper class, then let's do the Handler!!!
And this is how it looks my Map (XML)

In case you have to receive the Array from your Stored Proc, you just have to write in your Handler somethig like this:

References: Using iBatis with a stored function returning a Collection Type and Oracle UDT Collections as IN and OUT parameters with iBatis

1 comment:

  1. Hi ,

    I am trying to pass a oracle user defined Type(Array of records) from Java to Oracle PL SQL.
    My Application server is Websphere Application Server 6.1 and database is Oracle 10g. I am using ojdbc1.4.jar as thin driver.
    The issue is that i am not able to pass the data from Java to PL SQL. AT the PL SQL side, the data is coming as empty.However when i try to run the same code in standalone application(without WAS) i am able to pass the data to PL SQL. So i assume that the issue is between WAS 6.1 and Oracle 10g. Can some one suggest a way out?

    ReplyDelete