If you see an unexpected 1111 number in your log when you get an error
with an inline parameter map and null values, chances are good that the
problem is that your driver does not like null values without an explicit
type. The integer value used for OTHER is 1111.
To tell i BATIS what the type is with an inline parameter, you add the type name from
java.sql.Types after the property name and separate them with a colon character.
Here is an example of a mapped statement that specifies a database type:
where shipDate > #value:DATE#
Remember that we are working with XML . In the previous example, had
we wanted to create a statement named getOrderShippedBefore and
make the condition shipDate < #value:DATE# we would have had to use
< instead of < , because in XML , the less-than symbol means you are
starting a new element. A CDATA section could also be used, but be careful
with Dynamic SQL (chapter 9) and CDATA , because Dynamic SQL tags in
a CDATA section will not be parsed. Generally, you can get away with > in
XML , but it is probably better to be safe and use the > entity instead.
Null value replacement lets you treat “magic numbers” in your Java code as null
values in your database. Developing with “magic numbers” is a bad design for
most applications (in fact, we cannot think of a single case where it is the right
thing to do), and is only supported as a way for people to start using i BATIS in
spite of poor model design. If you need to have a null value in your database, you
should map it to a null value in your Java model as well.
In current releases of i BATIS , you can specify any value for the parameter map
using a name=value syntax. For example, the following example is equivalent to
the previous one:
<select id="getOrderShippedAfter" resultClass="hashmap">
where shipDate > #value,jdbcType=DATE#
Remember that an inline parameter map is just a shortcut to creating a parameter
map. If you get an error with a mapped statement telling you there was an error with
the parameter map YourNamespace.YourStatement-InlineParameterMap , look at
the inline parameter mapping for the statement YourStatement in the namespace