iBATIS參數理解淺析
iBATIS參數的學習,首先我們看看都有哪些iBATIS參數:
◆iBATIS參數之:原型參數
- ﹤select id="select1" parameterClass="java.lang.String" resultClass="AppLog"﹥
- select
- ID as id,
- TYPE as type,
- DESCR as descr
- from APP_LOG
- where ID = #id#
- ﹤/select﹥
sqlMapper.queryForObject("select0", id);
◆iBATIS參數之:Map類參數
- ﹤select id="select2" parameterClass="java.util.HashMap" resultClass="AppLog"﹥
- select
- ID as id,
- TYPE as type,
- DESCR as descr
- from APP_LOG
- where ID = #id#
- ﹤/select﹥
map.put("id", id);
AppLog log = (AppLog) sqlMapper.queryForObject("select0", map);
◆iBATIS參數之:對象參數
- ﹤select id="select3" parameterClass="AppLog" resultClass="AppLog"﹥
- select
- ID as id,
- TYPE as type,
- DESCR as descr
- from APP_LOG
- where ID = #id#
- ﹤/select﹥
AppLog p=new AppLog();
p.setId(id);
AppLog log = (AppLog) sqlMapper.queryForObject("select3", p);
- ﹤select id="select0" resultClass="AppLog"﹥
- select
- ID as id,
- TYPE as type,
- DESCR as descr
- from APP_LOG
- where ID = #id#
- ﹤/select﹥
Map參數 map.put("id", id);
AppLog log = (AppLog) sqlMapper.queryForObject("select0", map);
String參數 AppLog log = (AppLog) sqlMapper.queryForObject("select0", id);
對象參數 AppLog p=new AppLog();
p.setId(id);
AppLog log = (AppLog) sqlMapper.queryForObject("select0", p);
iBATIS參數的基本情況就介紹到這里,希望通過介紹使得你對iBATIS參數有一定的了解。
【編輯推薦】