Java Reference
In-Depth Information
firstName,
lastName,
address1,
address2,
city,
state,
postalCode,
country
from Account
where accountId = #accountId#
</select>
String parameter = "<parameter><accountId>3</accountId></parameter>";
Account account = (Account) sqlMapClient.queryForObject(
"Account.getByXmlId",
parameter);
Similarly, a DOM object can be passed into i BATIS to achieve the same results:
<select id="getByDomId" resultClass="Account" parameterClass="dom">
select
accountId,
username,
password,
firstName,
lastName,
address1,
address2,
city,
state,
postalCode,
country
from Account
where accountId = #accountId#
</select>
Document parameterDocument = DocumentBuilderFactory.newInstance()
.newDocumentBuilder().newDocument();
Element paramElement = parameterDocument
.createElement("parameterDocument");
Element accountIdElement = parameterDocument
.createElement("accountId");
accountIdElement.setTextContent("3");
paramElement.appendChild(accountIdElement);
parameterDocument.appendChild(paramElement);
Account account = (Account) sqlMapClient.queryForObject(
"Account.getByXmlId", parameterDocument);
As we mentioned earlier, that is a lot of code just to make your parameters into
XML . However, if you are working with a tool like Cocoon, or writing web services
in a framework that does not transform XML into objects for you, it can be useful.
Search WWH ::




Custom Search