iBATIS mybatis 配置 说明

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 类似于以上。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值