Mybatis中可以传递的参数
2014-04-02 10:22
323 查看
在mybatis中通常会接受参数,来根据参数限定一些操作数据库语句。传递的参数分类:
1.基本的参数String,int,Date等。在sql语句中通过#(参数名)获取到参数
<select id="selectPeople" parameterType="int" resultType="com.entry.people">
select * from
people where p_id = #{pid}
</select>
2.复杂数据类型:包含JAVA实体类、Map。通过 #{属性名} 或 #{map的Key值}即可获取传入的值
1)java实体类参数传值
<select id="selectPeople" parameterType="com.entry.people" resultType = "com.entry.people">
select * from people where p_sid = #{pid}
</select>
2) map集合
Map<String,Object> map = new
<String,Object> HashMap();
map.put("age",12);
map.put("sex","男");
<select id="selectPeople" parameterType="com.entry.people" resultType = "com.entry.people">
select * from people where p_age = #(age} ande p_sex = #{sex}
</select>
1.基本的参数String,int,Date等。在sql语句中通过#(参数名)获取到参数
<select id="selectPeople" parameterType="int" resultType="com.entry.people">
select * from
people where p_id = #{pid}
</select>
2.复杂数据类型:包含JAVA实体类、Map。通过 #{属性名} 或 #{map的Key值}即可获取传入的值
1)java实体类参数传值
<select id="selectPeople" parameterType="com.entry.people" resultType = "com.entry.people">
select * from people where p_sid = #{pid}
</select>
2) map集合
Map<String,Object> map = new
<String,Object> HashMap();
map.put("age",12);
map.put("sex","男");
<select id="selectPeople" parameterType="com.entry.people" resultType = "com.entry.people">
select * from people where p_age = #(age} ande p_sex = #{sex}
</select>
相关文章推荐
- MyBatis中可以用以下的方式来传递多个参数
- MyBatis 传递多个参数
- mybatis 使用一个参数传递数值 sql主要是使用到 in
- mybatis多个参数传递
- Mybatis的多参数传递问题
- jquery.validate的ajax方式验证[可以一个控件下一次传递多个参数,已经成功通过验证]
- Mybatis传递多个参数
- mybatis直接执行前台传递的sql语句(mapper参数即为sql字符串)
- @Param注解在Mybatis中的使用 以及传递参数的三种方式
- Mybatis传递多个参数进行SQL查询的用法
- mybatis传递多个参数
- MyBatis参数传递的问题
- Mybatis中模糊查询时相关的参数传递及xml配置
- mybatis新增用时用list传递参数
- MyBatis多参数传递之注解方式示例--转
- each用法、mybatis传递多个参数方法
- mybatis参数传递及其他标签
- MyBatis参数传递
- Mybatis传递多个参数
- 【mybatis】零碎拾起之参数传递