以前没有怎么用过IBATIS,用过后总结了一下。sqlmapconf文件的配置
<? xml version="1.0" encoding="UTF-8" ?>
<! DOCTYPE sqlMapConfig
PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-config-2.dtd" >
< sqlMapConfig >
< settings
cacheModelsEnabled ="true" <!--是否启用缓存机制-- >
lazyLoadingEnabled="true" <!-- 是否启用延迟加载机制 -->
enhancementEnabled="true" <!-- 是否启用字节码增强机制 -->
errorTracingEnabled="true" <!-- 是否启用错误处理机制 -->
maxRequests="32" <!-- 最大并发请求数 -->
maxSessions="10" <!-- 最大Session数 -->
maxTransactions="5" <!-- 最大并发事务数 -->
useStatementNamespaces="true"/> <!-- 是否启用名称空间 -->
</ sqlMapConfig >
<sqlMapConfig>
<settings cacheModelsEnabled="false"
enhancementEnabled="true"
lazyLoadingEnabled="false"
useStatementNamespaces="true"
statementCachingEnabled="true"
classInfoCacheEnabled="true"
maxSessions="1024"
maxTransactions="512"
maxRequests="5120" />
<typeAlias alias="mapModel" type="org.platform.models.MapModel" />
<typeAlias alias="mapResultModel" type="org.platform.models.MapResultModel" />
<sqlMap resource="config/xyhoa/sqlmaps/oracle/wf/sqlmap-deployment.xml" />
<sqlMap resource="config/xyhoa/sqlmaps/oracle/wf/sqlmap-tasks.xml" />
<sqlMap resource="config/xyhoa/sqlmaps/oracle/wf/sqlmap-jbpm4_deployprop.xml" />
</sqlMapConfig>
Spring中配置管理
<bean id="sqlMapClient_xyhoa"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation">
<value>classpath:config/xyhoa/sqlmaps/sql-map-config.xml</value>
</property>
<property name="dataSource" ref="dataSource_xyhoa" />
</bean>
<bean id="xyhoaSqlMapDao" abstract="true" class="org.platform.domain.spring.ibatis.BaseSqlMapClientDao" init-method="initialize">
<property name="dataSource">
<ref bean="dataSource_xyhoa" />
</property>
<property name="sqlMapClient">
<ref bean="sqlMapClient_xyhoa" />
</property>
<property name="sqlExecutor">
<ref bean="sqlExecutor" />
</property>
</bean>
事务管理器
<!-- Transaction manager for a single JDBC DataSource -->
<bean id="transactionManager_xyhoa"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource_xyhoa" />
</bean>
<tx:advice id="xyhoaTxAdvice" transaction-manager="transactionManager_xyhoa">
<tx:attributes>
<tx:method name="insert*" propagation="REQUIRED" rollback-for="Exception"/>
<tx:method name="update*" propagation="REQUIRED" rollback-for="Exception"/>
<tx:method name="delete*" propagation="REQUIRED" rollback-for="Exception"/>
<tx:method name="select*" read-only="true"/>
</tx:attributes>
</tx:advice>
<aop:config proxy-target-class="true">
<aop:pointcut id="xyhoaTx1" expression="execution(* com.xyh.xyhoa.service*..*.*(..))" />
<aop:advisor advice-ref="xyhoaTxAdvice" pointcut-ref="xyhoaTx1" order="1" />
</aop:config>