Java Reference
In-Depth Information
Note that in most cases you'll never need to write a custom type handler. i BA-
TIS has prebuilt type handlers to deal with 99 percent of the cases. Usually a cus-
tom type handler is only necessary if you're using an odd database or driver that
does not support the typical type mapping common to most databases. Avoid writ-
ing custom type handlers if you can, to keep your application simple.
3.6.7
The <sqlMap> element
The last section of the SqlMapConfig.xml file is where we configure the <sqlMap>
elements. This is where you start to get into the real “heavy lifting” that i BATIS can
do for you.
The <sqlMap> element is actually one of the simplest elements in this file,
because it only requires one of two attributes to be set.
The resource attribute is used if you want to put your SQL Map files on the
Java classpath and refer to them that way. Generally, this is the easiest way, because
they can be stored in a JAR file or a WAR file, and simply referenced relative to the
root of the classpath.
In other cases, you may want to be more explicit about the location of the files.
In those cases, you can use the url attribute. This attribute can use the
java.net.URL class to resolve the location of the file, so you can use any URL value
that can be understood by that class.
3.7 Summary
Installing i BATIS is a very simple process. In this chapter, we looked at the two ways
to get the framework and what to do with it once you have it. Because i BATIS was
designed to be simple to use, it has very few dependencies and can be extended to
use other tools very easily.
While JDBC is a very powerful API , it is also a low-level API , and writing solid
code that uses it can be difficult. With i BATIS you can step back from the complex-
ity of dealing with database components, and focus more on the business prob-
lems that you are trying to solve.
We looked at a simple i BATIS configuration—quite possibly the simplest case
ever written! In the next chapter, we will examine how to configure it in more
detail and how to make it fit into your application perfectly.
In this chapter, we also explored the i BATIS configuration files. When using
any framework it is essential to have a solid understanding of the fundamentals.
This chapter provided just that—an understanding of the fundamentals or a
quick reference guide.
Search WWH ::




Custom Search