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>

扫描二维码关注公众号,回复: 781084 查看本文章

sqlMapper.queryForObject("select0", id);

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);

对象参数

<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);

猜你喜欢

转载自mikzhang.iteye.com/blog/1175267