Java Reference
In-Depth Information
This procedure accepts three parameters and returns void. However, the third
parameter is out only, so depending on which of the other two parameters is
greater, it is replaced with one of them. To call this using i BATIS , you would create
a parameter map and a mapped statement:
<parameterMap id="maxOutProcedureMap" class="java.util.Map">
<parameter property="a" mode="IN" />
<parameter property="b" mode="IN" />
<parameter property="c" mode="OUT" />
<procedure id="maxOutProcedure"
{ call maximum (?, ?, ?) }
// Call maximum function
Map m = new HashMap(2);
m.put("a", new Integer(7));
m.put("b", new Integer(5));
sqlMap.queryForObject("Account.maxOutProcedure", m);
// m.get("c") should be 7 now.
Stored procedures can also return multiple rows of data, as mentioned earlier in
this chapter. This capability can be used to dramatically improve the performance
of complex queries over large data sets that cannot be optimized using traditional
SQL optimization techniques. Some examples of more difficult operations to opti-
mize are outer joins and filters requiring calculations. If you are planning on
using stored procedures for this purpose in your application, you should make
sure that you have a good understanding of the real bottlenecks, or you may end
up wasting time instead of saving it.
5.6 Summary
In this chapter, we looked at nearly all of the options for modifying data in a data-
base using i BATIS . After reading chapter 4 and this chapter, you should have all of
the information you need to create an application that maintains data using the
i BATIS framework.
In chapter 6, we continue to expand on what you have learned. We examine
more advanced query techniques to help you better leverage the investment you
have made in your database skills and platform.
Search WWH ::

Custom Search