spring-dao.xml配置
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation" value="classpath:/sql-map-config.xml"/>
<property name="dataSource" ref="dataSource"/>
</bean>
sql-map-config.xml配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<settings enhancementEnabled="true" maxTransactions="20"
maxRequests="32" maxSessions="10"/>
<sqlMap resource="sqlmaps/XXXSQL.xml"/>
</sqlMapConfig>
XXXSQL.xml配置
<sqlMap namespace="abcSQL">
<typeAlias alias="abc" type="com.ABC"/>
<resultMap id="abcResult" class="abc">
<result property="id" column="id"/>
<result property="name" column="name"/>
</resultMap>
自增主键,返回新值
<insert id="add" parameterClass="abc">
<![CDATA[
insert into abc(name)
values (#name:VARCHAR#)
]]>
<selectKey keyProperty="id" resultClass="java.lang.Long">
values IDENTITY_VAL_LOCAL()
</selectKey>
</insert>