1.传入参数和传出参数的区别
ibatis传入参数用的是parameterClass 传出参数用的是resultClass
iBatis:<select id="serchDemo" parameterClass="Map" resultClass="BaseResultMap"> </select>
mybatis传入参数用的是parameterType 传出参数用的是resultType
MyBatis:<select id="serchDemo" parameterType="Map" resultMap="BaseResultMap"> </select>
2.接收参数的区别
ibatis用的是# # 和 $ $
UPDATE STUDENT set age= #age# where id = #id#
mybatis用的是#{} 和 ${}
update STUDENT set age= #{age} where id = #{id}
(因为$有SQL注入的问题所以很少用)
3.条件的区别
ibatis属性判断非空条件用isNotNull 判空用isNull
值判断非空用isNotEmpty 判空用 isEmpty
property为属性名,prepend为属性与属性或者值与值之间的连接符号
dynamic标签是用来动态拼接条件的,可以根据有无条件动态拼接where
UPDATE STUDENT
<dynamic prepend="set">
<isNotNull property="age " prepend=",">
age = #age#
</isNotNull>
</dynamic>
<dynamic prepend="WHERE">
<isNotEmpty property="ID" prepend="and">
ID = #ID#
</isNotEmpty>
</dynamic>
mybatis比较简单,都是通过if标签去判断
test为属性名
if里面可以做非空判断,也可以做具体值得判断
where标签用来动态拼接where条件
select age from DIGGING_PLAN_PROCESS
<where>
<if test="id != null and id != ''">
and id= #{id}
</if>
</where>