自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

動態(tài)Mapped Statement在iBATIS中應(yīng)用

開發(fā) 后端
動態(tài)Mapped Statement在iBATIS中的應(yīng)用是怎么樣的呢?那么本文就向你介紹詳細的內(nèi)容。

動態(tài)Mapped Statement是如何在iBATIS中應(yīng)用呢?讓我們先看看實例:
 
Java代碼

  1. ﹤select id="dynamicGetAccountList" cacheModel="account-cache" resultMap="account-result"﹥  
  2.   select * from ACCOUNT  
  3.   ﹤isGreaterThan prepend="and" property="id" compareValue="0"﹥  
  4.       where ACC_ID=#id#  
  5.   ﹤/isGreaterThan﹥  
  6.   order by ACC_LAST_NAME  
  7. ﹤/select﹥ 

例子說明:

如果值小于0,那么sql語句就是:
 
Java代碼

  1. select * from ACCOUNT     
  2. order by ACC_LAST_NAME   

動態(tài)Mapped Statement應(yīng)用更復(fù)雜的例子:
 
Java代碼

  1. ﹤select id="dynamicGetAccountList"  resultMap="account-result"﹥     
  2.   select * from ACCOUNT     
  3.   ﹤dynamic prepend="WHERE"﹥     
  4.     ﹤isNotNull prepend="AND" property="firstName"﹥     
  5.      (ACC_FIRST_NAME=#firstName#     
  6.      ﹤isNotNull prepend="OR" property="lastName"﹥     
  7.        ACC_LAST_NAME=#lastName#     
  8.      ﹤/isNotNull﹥     
  9.      )     
  10.     ﹤/isNotNull﹥     
  11.     ﹤isGreaterThan prepend="and" property="id" compareValue="0"﹥     
  12.       ACC_ID=#id#     
  13.     ﹤/isGreaterThan﹥     
  14.   ﹤/dynamic﹥     
  15.   order by ACC_LAST_NAME     
  16. ﹤/select﹥   

動態(tài)Mapped Statement實例注解:

prepend:可被覆蓋的SQL語句組成部分

property:被比較的屬性

compareProperty:另一個用于和前者比較的屬性
 
compareValue用于比較的值
 
﹤isEqual﹥

﹤isNotEqual﹥

﹤isGreaterThan﹥

﹤isGreaterEqual﹥

﹤isLessThan﹥

﹤isLessEqual﹥

﹤isPropertyAvailable﹥:檢查是否存在該屬性

﹤isNotPropertyAvailable﹥:
 
﹤isNull﹥:檢查屬性是否為null

﹤isNotNull﹥

﹤isEmpty﹥:檢查Collection.size()的值,屬性String或String.valueOf()值是否為null或空

﹤isNotEmpty﹥:

﹤isParameterPresent﹥:檢查是否存在參數(shù)對象(不為null)

﹤iterate﹥遍歷集合:
 
Java代碼

  1. ﹤iterate prepend="and" property="userNameList" open="(" close=")" conjunction="or"﹥     
  2.   username=#userNameList[]#     
  3. ﹤/iterate﹥   

property屬性:類型為java.util.List的用于遍歷的元素

open屬性:整個遍歷內(nèi)容開始的字符串,用于定義括號

close屬性:整個便利內(nèi)容結(jié)束的字符串

conjunction:每次遍歷內(nèi)容之間的字符串,用于定義AND或OR

動態(tài)Mapped Statement在iBATIS中的應(yīng)用就向你介紹到這里,對它了解些了么?

【編輯推薦】

  1. iBATIS入門程序六大步詳解
  2. iBATIS DAO事務(wù)淺析
  3. iBATIS使用$和#的一些理解
  4. iBATIS分頁的一些理解
  5. iBATIS應(yīng)用之SQLMap API編程淺析
責(zé)任編輯:仲衡 來源: JDNIS
相關(guān)推薦

2009-07-15 17:58:07

iBATIS 動態(tài)映射

2009-07-20 14:56:18

iBATIS.NET動態(tài)選擇DAO

2009-07-15 13:11:25

ibatis動態(tài)查詢

2009-07-22 11:11:39

iBATIS分頁實例ObjectDataS

2009-07-17 10:32:45

iBATIS MapB

2009-07-22 13:04:41

iBATIS動態(tài)查詢

2010-04-30 08:47:22

Oracle分頁存儲

2009-07-16 13:08:09

iBATIS快速創(chuàng)建應(yīng)

2024-08-08 07:13:36

2009-07-17 10:59:59

iBATIS接口

2009-07-15 17:31:08

iBATIS Ecli

2009-07-20 15:27:22

Castle.DynaiBATIS.NET

2009-07-14 17:12:26

ibatis自動代碼生

2009-12-10 14:56:10

動態(tài)路由技術(shù)

2012-07-16 01:41:54

ibatis搭建應(yīng)用

2021-05-21 07:59:40

應(yīng)用程序設(shè)計動態(tài)庫函數(shù)

2011-04-14 09:28:56

IIS 7.0

2009-08-11 14:26:56

C#動態(tài)調(diào)用WebSe

2009-07-17 14:55:38

ibatis官方

2009-07-21 11:17:46

iBATISDAO的配置
點贊
收藏

51CTO技術(shù)棧公眾號