09.11 Mybatis generator不生成example

Mybatis Generator默認設置會生成一大堆羅哩羅嗦的Example類,主要是用各種不同的條件來操作數據庫,大部分是用不到的,用到的時候手工修改mapper和接口文件就行了。


<table> enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
enableSelectByExample="false" selectByExampleQueryId="false" >
<property>
/<table>

注意:

domainObjectName:表名

設置駝峰命名法 :<property>

Example類用於構造複雜的篩選條件。

基本概念

  • Criterion
  • Criterion是最基本,最底層的Where條件,用於字段級的篩選,feild用於指代字段名字,列舉如下:
  • 只有一個條件,不需要其他參考值
  • feild IS NOLL
  • feild IS NOT NULL
  • 與一個參考值進行算數運算
  • feild > value
  • feild >= value
  • feild = value
  • feild <> value
  • feild <= value
  • feild < value
  • 與一個參考值進行模糊查詢,參值中的%,?只能在構造查詢條件時手動指定。
  • feild LIKE value
  • feild NOT LIKE value
  • 介於兩個參考值之間
  • feild BETWEEN value AND secondValue
  • 在或不在一個參考值集合中,item來自於value集合
  • feild IN (item,item,item,...)
  • feild NOT IN (item,item,item,...)
  • MyBatis Generator會為每個字段產生如上的Criterion,如果表的字段比較多,產生的Example類會十分龐大。理論上通過Example類可以構造你想到的任何篩選條件。
  • Criteria
  • Criteria包含一個Cretiron的集合,每一個Criteria對象內包含的Cretiron之間是由AND連接的,是邏輯與的關係。
  • oredCriteria
  • Example內有一個成員叫oredCriteria,是Criteria的集合,就想其名字所預示的一樣,這個集合中的Criteria是由OR連接的,是邏輯或關係。oredCriteria就是ORed Criteria。
Mybatis generator不生成example


分享到:


相關文章: