SqlMapClientFactoryBean的主要的几个属性
1 configLocations --ibatis的配置文件的地址
2 mappingLocations --Ibatis映射文件路径
3 sqlMapClientProperties --ibatis的sqlmapclient的属性
4 dataSource --数据源
5 useTransactionAwareDataSource --使用spring 的事物包装数据源
6 transactionConfigClass --事物配置类
7 transactionConfigProperties --事物配置属性
8 sqlMapClient
sqlMapConfig.xml文件解释
cacheModelsEnabled
是否启用SqlMapClient上的缓存机制。建议设为"true"
enhancementEnabled
是否针对POJO启用字节码增强机getter/setter的调用效能,避免Reflect所带来的性能开销。同时,这也为Lazy Loading带来提升。建议设为"true"
errorTracingEnabled
是否启用错误日志,在开发期间建议设为"true" 以方便调试
lazyLoadingEnabled
是否启用延迟加载机制,建议设为"true"
maxRequests
最大并发请求数(Statement并发数)
maxTransactions
最大并发事务数
maxSessions 最大Session数。即当前最大允许的并发SqlMapClient数。
useStatementNamespaces
是否使用Statement命名空间。
<bean id="sqlMapClient"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation"
value="classpath:config/sql-map-config.xml" />
<property name="mappingLocations"
value="classpath:ibatis/sqlmap/*/*.xml" />
<property name="dataSource" ref="dataSource" />
</bean>
sql-map-config.xml
<sqlMapConfig>
<settings cacheModelsEnabled="true" enhancementEnabled="true" lazyLoadingEnabled="true"
maxRequests="32" maxSessions="10" maxTransactions="5" useStatementNamespaces="true" />
</sqlMapConfig>
用 mappingLocations 配置ibatis的映射文件,并使用了 * 通配符。这个做法省了些麻烦,就不必要在sql-map-config.xml文件中加入类似于:
<sqlMap resource="config/User.xml"/> 的引入映射文件了。
mybatis 类似于以上。
iBATIS mybatis 配置 说明
猜你喜欢
转载自haidaoqi3630.iteye.com/blog/2171270
今日推荐
周排行