日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

MyBatis Generator配置文件翻译

發布時間:2023/12/9 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MyBatis Generator配置文件翻译 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

From: https://www.cnblogs.com/GaiDynasty/p/4088531.html

<classPathEntry>

驅動文件指定配置項

<classPathEntry location="/Program Files/IBM/SQLLIB/java/db2java.zip" />

<columnOverride>

將數據庫中的字段重命名為實體類的屬性

column?數據庫中字段名

property?POJO屬性名

javaType POJO類型

jdbcType?數據庫字段類型

<table schema="DB2ADMIN" tableName="ALLTYPES" domainObjectName="Customer" ><property name="useActualColumnNames" value="true"/><generatedKey column="ID" sqlStatement="DB2" identity="true" /><columnOverride column="DATE_FIELD" property="startDate" /><ignoreColumn column="FRED" /><columnOverride column="LONG_VARCHAR_FIELD" jdbcType="VARCHAR" /></table>

<columnRenamingRule>

按規則將數據庫中的字段重命名為實體類的屬性

<table schema="DB2ADMIN" tableName="ALLTYPES" domainObjectName="Customer" ><columnRenamingRule searchString="^CUST_" replaceString="" />.. </table>

<commentGenerator>

代碼上面的注釋規則

子屬性:property

porperties:

suppressAllComments? false時打開注釋,true時關閉注釋

suppressDate? false時打開時間標志,true時關閉...真是反人類啊

<commentGenerator><property name="suppressDate" value="true" /> </commentGenerator>

<context>

這個實在不知道怎么解釋,反正就是大環境

targetRuntime?可選項,可填值為MyBatis3,MyBatis3Simple(默認的),Ibatis2Java2,Ibatis2Java5

<context id="DB2Tables" targetRuntime="MyBatis3">... </context>

<generatedKey>

指定自增加以及Id

column?字段

sqlStatement?數據庫語句,可以為MySql,DB2,SqlServer,SyBase等http://mybatis.github.io/generator/configreference/generatedKey.html

identity?true為id,false不為id

<table schema="DB2ADMIN" tableName="ALLTYPES" domainObjectName="Customer" ><property name="useActualColumnNames" value="true"/><generatedKey column="ID" sqlStatement="DB2" identity="true" /><columnOverride column="DATE_FIELD" property="startDate" /><ignoreColumn column="FRED" /><columnOverride column="LONG_VARCHAR_FIELD" jdbcType="VARCHAR" /></table>

<ignoreColumn>

忽略字段

column?字段名

<table schema="DB2ADMIN" tableName="ALLTYPES" domainObjectName="Customer" ><ignoreColumn column="FRED" />..</table>

<javaClientGenerator>

Mapper生成配置

type?XMLMAPPER配置文件方式,ANNOTATEDMAPPER注解方式

http://mybatis.github.io/generator/configreference/javaClientGenerator.html

<javaClientGenerator type="XMLMAPPER"targetPackage="dao.mapper" targetProject="app"><property name="enableSubPackages" value="true" /></javaClientGenerator>

<javaModelGenerator>

實體類生成配置

http://mybatis.github.io/generator/configreference/javaModelGenerator.html

<javaModelGenerator targetPackage="domain"targetProject="app"><property name="enableSubPackages" value="true" /><property name="trimStrings" value="false" /></javaModelGenerator>

<javaTypeResolver>

mybatis里專門用來處理NUMERIC和DECIMAL類型的策略

<javaTypeResolver><property name="forceBigDecimals" value="true" /> </javaTypeResolver>

<jdbcConnection>

jdbc配置,不解釋了哈

<jdbcConnection driverClass="COM.ibm.db2.jdbc.app.DB2Driver"connectionURL="jdbc:db2:MBGTEST"userId="db2admin"password="db2admin"> </jdbcConnection>

<sqlMapGenerator>

生成sql語句的xml文件

在mybatis2里是必須的,在mybatis3中,只有用XML方式的時候才是需要的。

<sqlMapGenerator targetPackage="test.model"targetProject="\MyProject\src"><property name="enableSubPackages" value="true" /> </sqlMapGenerator>

總結

以上是生活随笔為你收集整理的MyBatis Generator配置文件翻译的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。