Java Reference
In-Depth Information
an easy way to start adding selection criteria to your mapped statements and can be
designated by using one of two different methods.
The first method is by using the hash (#) syntax. Here is an example using that
syntax to pass a simple inline parameter in to get a single Account bean out by its
accountId value:
<select id="getByIdValue" resultClass="Account">
select
accountId,
username,
password,
firstName,
lastName,
address1,
address2,
city,
state,
postalCode,
country
from Account
where accountId = #value#
</select>
The #value# string in this mapped statement is a placeholder that tells i BATIS that
you are going to pass in a simple parameter that it needs to apply to the SQL
before executing it. This mapped statement could be called this way:
account = (Account) sqlMap.queryForObject(
"Account.getByIdValue",
new Integer(1));
Let's take a few minutes to look into what the i BATIS framework does with this
statement. First, it looks up the mapped statement named Account.getByIdValue ,
and transforms the #value# placeholder into a prepared statement parameter:
select
accountId,
username,
password,
firstName,
lastName,
address1,
address2,
city,
state,
postalCode,
country
from Account
where accountId = ?
Search WWH ::




Custom Search