• Mybatis Doc Configuration XML


    The MyBatis configuration contains settings and properties.

    properties

    Properties can be configured in a typical Java Properties file instance, or passed in through sub-elements of the properties element.

    <properties resource="org/mybatis/example/config.properties">
      <property name="username" value="dev_user"/>
      <property name="password" value="F2Fa"/>
    </properties>
    

    The properties can then be used throughout the configuration files to substitute values that need to be dynamically configured.

    <dataSource type="POOLED">
      <property name="driver" value="${driver}"/>
      <property name="url" value="${url}"/>
      <property name="username" value="${username}"/>
      <property name="password" value="${password}"/>
    </dataSource>
    

    settings

    These are extremely important tweaks that modify the way that MyBatis behaves at runtime.

    <settings>
      <setting name="cacheEnabled" value="true"/>
      <setting name="lazyLoadingEnabled" value="false"/>
      <setting name="aggressiveLazyLoading" value="false"/>
      <setting name="multipleResultSetsEnabled" value="true"/>
      <setting name="useColumnLabel" value="true"/>
    </settings>
    

    typeAliases

    A type alias is simply a shorter name for a Java type.

    typeHandlers

    TypeHandler is used to retrieve the value in a means appropriate to the Java type.

    Handling Enums

    If you want to map an Enum, you'll need to use either EnumTypeHandler or EnumOrdinalTypeHandler.

    objectFactory

    Each time MyBatis creates a new instance of a result object, it uses an ObjectFactory instance to do so.

    plugins

    MyBatis allows you to intercept calls to at certain points within the execution of a mapped statement.

    environments

    MyBatis can be configured with multiple environments. This helps you to apply your SQL Maps to multiple databases for any number of reasons. if you want to connect to two databases, you need to create two instances of SqlSessionFactory.

    databaseIdProvider

    MyBatis is able to execute different statements depending on your database vendor.

    mappers

    Java doesn’t really provide any good means of auto-discovery in this regard, so the best way to do it is to simply tell MyBatis where to find the mapping files.

  • 相关阅读:
    jms学习笔记
    UML类图与类的关系详解
    javolution学习--介绍
    Eclipse中10个最有用的快捷键组合
    [疯狂Java]JDBC:PreparedStatement预编译执行SQL语句
    Oracle OLAP 与 OLTP 介绍
    DRDS SQL兼容性
    DRDS 概述
    跨时代的分布式数据库 – 阿里云DRDS详解(转)
    java.net.UnknownHostException: www.terracotta.org
  • 原文地址:https://www.cnblogs.com/feiqiangsheng/p/15839332.html
Copyright © 2020-2023  润新知