In previous chapters we looked at how to configure i BATIS SqlMap s, and you saw
an example of a mapped statement. You should now have a foundation on which
to start building more of the database access layer for an application.
This chapter and the next examine mapped statements in greater detail, and dis-
cuss using SQL maps to create them. In this chapter, we first look at mapped state-
ments in general and what you need to know to use them. Then we explain how to
get data out of the database using mapped statements that return typed objects
(JavaBeans), and how to pass in parameters to limit the data being returned. In
chapter 5, you will learn how to update a database with mapped statements.
4.1 Starting with the basics
There are a few conceptual challenges to understand before getting started with
i BATIS . You will need to have a basic understanding of Java development using
JavaBeans. You will also need to know what i BATIS makes available in terms of the
types of SQL statements you can use, and the API that you need to use to execute
As mentioned before, i BATIS is not an object/relational mapping ( O/RM )
tool; it is a query mapping tool. Because of that, the API that we will be looking at
is not the only API you have available. You can still use any other API you want to
create the beans that your application will use or to access your database. So, if
you find that you are unable to accomplish something with i BATIS , you can still
use the straight JDBC API without too much concern about the repercussions.
Keep that freedom in mind as we look at what i BATIS does make available—while
it does not solve every problem, it does attempt to simplify most of your data
While the use of JavaBeans is not required by i BATIS , we do recommend using
them in most (but not all) cases. If you are new to Java, creating JavaBeans is quite
simple: a JavaBean is a reusable component that can be developed and then
assembled to create more sophisticated components and applications. The Java-
Bean specification (all 114 pages of it) is freely available from Sun. A simple
search at http://java.sun.com should yield this document.
We do not have that many pages to spare here, so we will try to condense the
specification down to something more relevant to i BATIS .