一、
1、两个参数都是int类型()
例子:
1
< select id="searchClassAllNum" resultType="int">
select count(*) from parkclass pc join parkclasstag pct on(pc.classtaglevel=pct.id)
join parent p on(pc.parentid=p.id)
where pc.parkid=#{0} and pct.id=#{1};//和dao方法里面的参数位置一致
</select>
2
<!-- 通过班级查找信息 -->
<select id="findAllMsgByTagId" parameterType="com.yunkuan.entity.ParkClass" resultMap="parkMap" >
select * from parkclass pc join parkclasstag pct on(pc.classtaglevel=pct.id)
join parent p on(pc.parentid=p.id)
where pc.parkid=#{parkid} and pct.id=#{classtaglevel}
</select>
2、采用Map传多参数.
例子:
Public
User
selectUser(Map paramMap);
selectUser"
resultMap="
"
>
select
*
from
user
where
user_name = #{userName,jdbcType=
VARCHAR
}
and
user_area=#{userArea,jdbcType=
VARCHAR
}
Public
User
selectUser(String
name
,String area);
<
select
id=
"selectUser"
resultMap=
"BaseResultMap"
>
select
*
from
user_user_t
where
user_name = #{0}
and
user_area=#{1}
</
select
>
其中,#{0}代表接收的是dao层中的第一个参数,#{1}代表dao层中第二参数,更多参数一致往后加即可。
4、
Public
User
selectUser(@param(“userName”)String name,@param(“userArea”)String area);
<
select
id=
" selectUser"
resultMap=
"BaseResultMap"
>
select
*
from
user_user_t
where
user_name = #{userName,jdbcType=
VARCHAR
}
and
user_area=#{userArea,jdbcType=
VARCHAR
}
</
select
>
<insert id="addParent" useGeneratedKeys="true" keyProperty="id"
parameterType="com.yunkuan.entity.Parent">
insert into parent (parentname,parentpass,phone,address,balance,timer)values(#{parentname},#{parentpass},#{phone},#{address}#{balance},#{timer})
</insert>
java:
parkDao.addParent(parent);
int parentid=parent.getId();//获取刚添加parent的id