img
Table 11-2. MyBatis Mapper Interface and Mapping File
File Type
Purpose
Example
Domain object
The POJO that queries will be
The Contact class (under the package
mapped to.
com.apress.prospring3.ch11.domain) that
holds the information of a contact
Mapper interface
The Java interfaces that MyBatis will
The ContactMapper interface (under the
scan for and register as
package
MapperFactoryBeans. All the database
com.apress.prospring3.ch11.persistence)
operations supported for the relating
for the Contact domain object
domain object will be defined here.
The ContactMapper.xml file (under the folder
SQL mapping
The XML configuration file that
src/main/resources with the package name
configuration file
stores the details of mapping
com.apress.prospring3.ch11.persistence)
between SQL queries and domain
objects. The file should be in the
project's classpath and have the
same name as the mapper interface.
A diagram can help in understanding the structure better. For example, to implement the findAll()
method of the ContactService interface, the files and their content will look like the one in Figure 11-3.
Figure 11-3. MyBatis mapping files structure
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home