码迷,mamicode.com
首页 > 其他好文 > 详细

ibatis初识

时间:2018-03-07 16:25:02      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:入参   pen   delete   name   bean   iba   nbsp   地址   empty   

ibatis

<sqlmap></sqlmap>

属性:namespace=‘链接的dao层地址

<sqlMap namespace="ZrsDao">

这里有配置所以可直接只配置dao层

 

<typeAlias/>单标签,传入和得到的参数的类型

<typeAlias alias="zrsBean" type="cn.mos.tobacco.zrs.bean.ZrsBean"/>

 

sql标签<select></select>

<update></update>

<delete></delete>

<insert></insert>

属性:id = "xxxxx" :对应dao层的执行语句 

resuletClass = "zrsBean"  : 得到结果类型

parameterClass = “zrsBean” :传入参数类型

 

sql语句标签

<isNotNull propend = "and"  property = "zrsBean.zrsid">

zrsid = # zrsBean.zrsid#

</isNotNull>  

当zrsBean的zrsid值不为null的时候,插入语句

<isNull></isNull>

当传入参数为null的时候,插入sql语句

<isNotEmpty></isNotEmpty> 

属性同上,当传入参数的值不为空的时候,插入语句

<isEmpty></isEmpty>

当传入参数为空的时候插入语句

<isEqual prepend = "and" property = "zrsBean.type" compareValue = "1">

type = #type#

</isEqual>

compareValue也可换成compareProperty = "zrsBean.xxxx"  ,此时是当传入参数的xxxx属性和type属性相同时拼接sql语句

当传入参数的type = 1的时候,拼接其中的sql语句

<include/>

属性ref = "要拼接sql的id"

这个与MySQL相同

 

ibatis初识

标签:入参   pen   delete   name   bean   iba   nbsp   地址   empty   

原文地址:https://www.cnblogs.com/19960715lww/p/8522784.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!