Java Reference
In-Depth Information
public int delete(Integer accountId);
public List<Account> getAccountListByExample(
Account account);
public List<Map<String, Object>>
getMapListByExample(Account account);
public List<IdDescription>
getIdDescriptionListByExample(Account account);
public Account getById(Integer accountId);
public Account getById(Account account);
}
This is a reasonable interface for the account table—we have all the basic CRUD
operations, as well as a few more convenience methods to make the API simpler to
use. Because we are talking primarily about i BATIS , let's start our DAO implemen-
tations with a SQL Map-based version of the interface we defined earlier. First, we
will look at the dao.xml that is used to describe the configuration for i BATIS .
10.4.1
Configuring the DAO in iBATIS
Listing 10.7 shows a DAO configuration that uses a single SQL Map-based DAO .
We define a context named sqlmap that will be defined in a SqlMapConfig.xml file
which is available on the classpath (for example, if this were used in a web applica-
tion, that file would live in /WEB-INF/classes/ ).
Listing 10.7
Sample iBATIS dao.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE daoConfig
PUBLIC
"-//ibatis.apache.org//DTD DAO Configuration 2.0//EN"
"http://ibatis.apache.org/dtd/dao-2.dtd">
<daoConfig>
<context id="sqlmap">
<transactionManager type="SQLMAP">
<property name="SqlMapConfigResource"
value="SqlMapConfig.xml"/>
</transactionManager>
<dao interface="com.mycompany.system.dao.AccountDao"
implementation=
"com.mycompany.system.dao.sqlmap.AccountDaoImpl"/>
</context>
</daoConfig>
Search WWH ::




Custom Search