Mybatis設置主鍵自增


<insert id="insertArea" useGeneratedKeys="true" keyProperty="areaId"
        keyColumn="area_id">
        INSERT INTO
        tb_area(area_name,area_desc,priority,
        create_time,last_edit_time)
        VALUES
        (#{areaName},#{areaDesc},#{priority},
        #{createTime},#{lastEditTime})
    </insert>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
    <!-- 配置全局屬性 -->
    <settings>
        <!-- 使用jdbc的getGeneratedKeys獲取數據庫自增主鍵值 -->
        <setting name="useGeneratedKeys" value="true" />

        <!-- 使用列標簽替換列別名 默認:true -->
        <setting name="useColumnLabel" value="true" />

        <!-- 開啟駝峰命名轉換:Table{create_time} -> Entity{createTime} -->
        <setting name="mapUnderscoreToCamelCase" value="true" />
    </settings>
    <plugins>
        <plugin interceptor="com.imooc.o2o.dao.split.DynamicDataSourceInterceptor">
        </plugin>
    </plugins>
</configuration>
mybatis-config

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM