Depending on the structure of the XML that you are starting with, it could be eas-
ier to use XSL to transform it into the structure required by i BATIS than to process
the XML and turn it into a Java object, which is your alternative in those cases.
The i BATIS framework also allows you to create XML results from mapped state-
ments. When running a mapped statement that returns XML , you get a complete
XML document for each returned object.
To use this feature, you create a mapped statement that has a result class of
xml . Here is a simple example:
<select id="getByIdValueXml" resultClass="xml"
where accountId = #value#
String xmlData = (String) sqlMap.queryForObject(
The results returned in this case will look like this (well, not exactly; we added
some whitespace and line feeds to make it more readable):
<?xml version="1.0" encoding="UTF-8"?>
Getting that data back is real handy if you have a single record that you want to get
as an XML document. If you want to get multiple objects, you can do that as well:
<select id="getAllXml" resultClass="xml" xmlResultName="account">