Java Reference
In-Depth Information
/org
/example
/myapp
/domain
/persistence
/presentation
/service
Given this structure, we can refer to the persistence package using the fully quali-
fied classpath of
org/example/myapp/persistence
. A good place to put our maps
might be in
org/example/myapp/persistence/sqlmaps
, which would look like this
in the structure:
/org
/example
/myapp
/domain
/persistence
/sqlmaps
SqlMapConfig.xml
Person.xml
Department.xml
/presentation
/service
Alternatively, if you want a more shallow structure for configuration files, you
could put the mapping files in a common configuration package. For example,
we could use
config/sqlmaps
, which would look like this:
/config
/sqlmaps
SqlMapConfig.xml
Person.xml
Department.xml
/org
/example
/myapp
/domain
/persistence
/presentation
/service
With your mapping files on the classpath, i
BATIS
makes it easy to load these files
using the included
Resources
utility class. This class contains methods like
getRe-
sourceAsReader()
, which is compatible with
SqlMapBuilder
. So given the previous
classpath, we could load
SqlMapConfig.xml
as follows:
Reader reader = Resources
.getResourceAsReader("config/maps/SqlMapConfig.xml");