ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig Tataryn" <crai...@tataryn.net>
Subject Stored procedure help.
Date Mon, 11 Feb 2008 23:27:02 GMT
Hi, relatively new to iBatis and have a question about a stored procedure I
need to call that has one IN parameter and several OUT parameters.  The idea
is, someone would call this stored proc to return exactly 1 customer from
the database.  The IN parameter corresponds to the customer's id, the OUT
parameters consist of a bunch of properties on a Customer object as well as
an extra STATUS parameter which does not exist on the Customer object, but
instead indicates whether a retrieval problem happened (for instance the ID
you passed to the stored proc didn't exist in the DB for any customers).

So for instance, given the Customer class:

public class Customer {
  private String name;
  private String email;
  private String gender;
}

And a stored proc that looked like this:
CREATE OR REPLACE PROCEDURE CUSTOMER_RD
    -- read a record from the table CUSTOMER
(
    CUST_ID IN NUMERIC,
    CUST_NAME OUT VARCHAR2,
    CUST_EMAIL OUT VARCHAR2,
    CUST_GENDER OUT CHAR,
    STATUS OUT NUMERIC
)
.
.
.

I know how I could code an sqlMap such that each of OUT parameters get's
populated into a Map entry, then I would manually iterate through the Map
and populate a Customer object (disregarding the STATUS param for the time
being), however what I'm hoping to do is instead get a map back from iBatis
which looks like so:

{
    "customer" => Customer
    "status" => int
}

Is this possible?  If so, what might the corresponding sqlMap look like?

Thanks

Mime
View raw message