日期:2014-05-16 浏览次数:20522 次
1.??? ibatis实例配置?
一个典型的配置文件如下(具体配置项目的含义见后):?
<? xml version="1.0" encoding="UTF-8"??? ?>?
<! DOCTYPE sqlMapConfig?
????? PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0/?
????? "http://www.ibatis.com/dtd/sql-map-config-2.dt?
<sqlMapConfig >?
???? < settings?
?????? cacheModelsEnabled ="true"??????
????? enhancementEnabled ="true"??????
????? lazyLoadingEnabled ="true"??????
????? errorTracingEnabled ="true"??????
????? maxRequests ="32"???????????
????? maxSessions ="10"???????????
????? maxTransactions ="5"??????????
????? useStatementNamespaces ="false"????
?????? />?
???? < transactionManager??? type ="JDBC" >?
???? < dataSource??? type ="SIMPLE" >?
???????? < property??? name ="JDBC.Driver"??? value ="com.p6spy.engine.spy.P6SpyDriver" />?
???????? < property??? name ="JDBC.ConnectionURL"??? value ="jdbc:mysql://localhost/sample" />?
???????? < property??? name ="JDBC.Username"??? value ="user" />?
???????? < property??? name ="JDBC.Password"??? value ="mypass" />?
???????? < property??? name ="Pool.MaximumActiveConnections"??? value ="10" />?
???????? < property??? name ="Pool.MaximumIdleConnections"??? value ="5" />?
???????? < property??? name ="Pool.MaximumCheckoutTime"??? value ="120000" />?
???????? < property??? name ="Pool.TimeToWait"??? value ="500" />?
???????? < property??? name ="Pool.PingQuery"??? value ="select 1 from ACCOUNT" />?
???????? < property??? name ="Pool.PingEnabled"??? value ="false" />?
???????? < property??? name ="Pool.PingConnectionsOlderThan"??? value ="1" />?
???????? < property??? name ="Pool.PingConnectionsNotUsedFor"??? value ="1" />?
?????? </ dataSource >?
???? </ transactionManager >?
???? < sqlMap??? resource ="com/ibatis/sample/User.xml" />?
</ sqlMapConfig >???
⑴ Settings 节点?
cacheModelsEnabled?
是否启用SqlMapClient上的缓存机制。 建议设为"true"?
enhancementEnabled?
是否针对POJO启用字节码增强机getter/setter的调用效能,避免Reflect所带来的性能开销。同时,这也为Lazy Loading带来提升。 建议设为"true"?