You can see that in approximately 14 lines of code we have accomplished what
took us several times that to accomplish with Java code or a stored procedure.
Since iBATIS uses PreparedStatement s internally, we were able to gain security
against SQL injection and gain the performance of the parameterized SQL . By
keeping the SQL in a simple XML file that resides with our Java source code, we
are also able to more easily maintain our SQL and deploy it with our application.
If iBATIS were in the analysis against straight Java or a stored procedure, there
would be no question as to which would be the logical winner.
8.6 T he future of Dynamic SQL
iBATIS is already looking into the future and making moves to improve Dynamic
SQL . Nearly everything you we have learned in this chapter will continue to be rel-
evant in the future of Dynamic SQL . That aside, it is important that you know the
direction iBATIS is heading with its Dynamic SQL .
The initial idea of the Dynamic SQL tag set was developed in iBATIS version 1. x .
The Dynamic SQL tag set was based largely on concepts borrowed from the Struts
taglibs (see Ted Husted's Struts in Action [Manning, 2002] for more details). As
standards have improved in the Java community, iBATIS has sought once again to
borrow concepts from more standard Java concepts and incorporate them into
iBATIS . Two areas in need of improvement have emerged: a simplified and more
robust tag set, and a simple expression language that can be used in conjunction
with the tags. Let's take a moment and look at where iBATIS will be making
improvements in Dynamic SQL .
Simplified conditional tags
Currently iBATIS boasts a healthy 16 tags that are used to accomplish Dynamic
SQL . These tags are all very specific. In an effort to provide for more general-pur-
pose conditional tags, the iBATIS team plans to introduce a simplified tag set
alongside the existing. The goal is that the new-generation Dynamic SQL tags will
eventually phase out the old. The new-generation Dynamic SQL will be modeled
after JSTL (Java Standard Tag Library). This would reduce our now 16 tags to a
mere 6 tags. As of this writing, the proposed new tags are <choose> , <when> , <oth-
erwise> , <if> , <foreach> , and <while> . For the most part, these tags will function
in an identical way to their JSTL sister tags, with the exception that they will con-
tain the additional prepend , open , close , and removeFirstPrepend attributes.