`
FightingSky
  • 浏览: 5129 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

ibatis3配置详解

阅读更多
Sample config file:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE configuration PUBLIC "-//ibatis.apache.org//DTD Config 3.0//EN" "http://ibatis.apache.org/dtd/ibatis-3-config.dtd">

<configuration>

<properties resource="database.properties">
</properties>

<settings>
  <setting name="cacheEnabled" value="true"/>
  <setting name="lazyLoadingEnabled" value="true"/>
  <setting name="multipleResultSetsEnabled" value="true"/>
  <setting name="useGeneratedKeys" value="false"/>
<!--  <setting name="enhancementEnabled" value="false"/>-->
  <setting name="defaultExecutorType" value="SIMPLE"/>
  <setting name="defaultStatementTimeout" value="25000"/>
</settings>

<typeAliases>
  <typeAlias type="com.ibatis.Student" alias="student" />
</typeAliases>
  
<typeHandlers>
  <typeHandler handler="com.ibatis.ExampleTypeHandler" jdbcType="VARCHAR" javaType="String"/>
  <!--这样会覆盖原来ibatis默认的string varchar转换器-->
</typeHandlers>

<!--ibatis使用objectFactory去创建result object的实例对象 -->
<objectFactory type="com.ibatis.ExampleObjectFactory">
  <property name="" value=""/>
</objectFactory>

<!--ibatis允许插件截断以下方法调用
  Executor(update,query,flushStatements,commit,rollback,getTransaction,close,isClosed)
  ParameterHandler(getParameterObject,setParameters)
  ResultSetHandler(handleResultSets,handleOutputParameters)
  StatementHandler(prepare,parameterize,batch,update,query)
必须在理解这些方法的基础上很小心的使用插件,不然很容易破坏ibatis的核心 -->
<plugins>
  <plugin interceptor="com.ibatis.ExamplePlugin">
  <property name="" value=""/>
  </plugin>
</plugins>

<environments default="development">
  <environment id="development">
  <!--事务控制类型
    JDBC:根据jdbc控制事务的提交和回滚
    MANAGED:将事务控制转交给容器 
    -->
  <transactionManager type="JDBC" />
  
  <!--数据源类型:
    1.UNPOOLED:不使用池技术,在请求到来时直接打开或者关闭数据库连接
    必须配置的参数:driver、url、username、password
    可选参数:使用driver.xxx来配置,如:driver.encoding=UTF8
    -->
  <dataSource type="UNPOOLED">
    <property name="driver" value="${driver}" />
    <property name="url" value="${url}" />
    <property name="username" value="${username}" />
    <property name="password" value="${password}" />
  </dataSource>
  
  <!--2.POOLED:使用数据库连接池  
  <dataSource type="POOLED">
    <property name="poolMaximumActiveConnections" value="10"/>
    <property name="poolMaximumIdleConnections" value=""/>
    <property name="poolMaximumCheckoutTime" value="20000"/>
    <property name="poolTimeToWait" value="20000"/>
    <property name="poolPingQuery" value="NO PING QUERY SET"/>
    <property name="poolPingEnabled" value="false"/>
    <property name="poolPingConnectionsNotUsedFor" value="0"/>
  </dataSource>
  -->
  
  <!--3.JNDI 使用env.xxx配置可选参数,如:env.encoding=UTF8  
  <dataSource type="JNDI">
    <property name="initial_context" value=""/>
    <property name="data_source" value=""/>
  </dataSource>
  -->
  
  </environment>
</environments>

<mappers>
  <mapper resource="studentSqlMapper.xml" />
<!--  <mapper url="file:///var/sqlmaps/AuthorMapper.xml"/>-->
</mappers>

</configuration> 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics