The example in listing 4.2 uses the remapResults attribute combined with
Dynamic SQL to demonstrate how to change the data returned from a
mapped statement on the fly. While Dynamic SQL is not covered until chapter 8,
this example uses it to create a mapped statement where the value of the
includePassword property determines the fields that are in the results. Depend-
ing on its value, you may or may not get the password field back in your results.
One thing to be aware of is that the performance hit for determining a result
map each and every time a statement is run may be prohibitive, so use this fea-
ture only when it is an absolute requirement.
Joining related data
There are times when you want to join multiple data tables into a single “flat-
tened-out” structure for reporting or other purposes. The i BATIS framework
makes this completely effortless, because it maps SQL statements to objects, not
tables to objects. There is literally no difference between mapping a single-table
select and a multitable select.
In chapter 7, we will look at how to perform more advanced multitable opera-
tions for the purpose of providing lists of child objects that are related to their
containing objects—such as a list of orders details for an order.
For now, we will simply restate that there is literally no difference between
mapping a single-table select and a multitable select.
We have talked about how SQL is similar to a function in that it has input val-
ues and, based on those input values, it produces output values. In the next sec-
tion, let's see how you provide those input values.
4.3 Mapping parameters
There are two ways to map parameters into your mapped statements: inline map-
ping and external mapping. Using inline parameter mapping means that you give
i BATIS some hints as to what you want, and let it figure out the details. External
parameter mapping, on the other hand, is more explicit—you tell i BATIS exactly
what you want it to do.
External parameter maps
You can specify up to six attributes when using an external parameter map. If you
do not specify them, i BATIS will try to decide on reasonable values using reflec-
tion, but this takes time and may not be as accurate. Table 4.4 lists the attributes
that are available for mapping parameters, and briefly describes how each is used.