ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From C.Ze...@ads.it
Subject Stored procedures returning a single value of basic type
Date Fri, 29 Sep 2006 12:34:41 GMT

Hi all.

I ask your attention about stored procedures (and functions) again.

Our tables are generally encapsulated by their corresponding package that
allows random access per column via the provided key.
A similar design approach applies to the unit testing packages which
provide some temporary test data.
For example for the TIPI_DATO table the Tipo_Dato and ut_Tipo_dato packages
contain functions such

   -- test row 4; key
   function get_key_4
   return Tipo_Dato.t_PK;
   pragma restrict_references( get_key_4, WNDS );

   -- "inezistent row" key: reserved
   function get_key_inexistent
   return Tipo_Dato.t_PK;
   pragma restrict_references( get_key_inexistent, WNDS );

The type  Tipo_Dato.t_PK   is a NUMBER(10)

In the unit test on the Java side we have to access those data (of "basic
type") via stored package functions like the ones above.

If I've understood well I should use queryForObject method to get an
"object" from the DB. Normally queryForObject is used along with resultMap

I've realized that using resultMap is not suitable

      "The resultMap is responsible for mapping JavaBeans properties to the
columns of a ResultSet produced by executing a query mapped

We have instead a single return value.

I scanned all the occurences of queryForObject and select in the
iBATIS-SqlMaps-2.pdf but I have not found any mention to this single-value
case (e.g, all the uses of the select are of the form

      select * from table

to select whole rows

Should I extract an entire row by using a JavaBean (I have to study yet
that case) and then should I access the single property via Java?
Or is there any way to get a single value (VARCHAR2, NUMBER, ...) returned
by a stored (package) function?

Thanks in advance for your help

View raw message