MyBatis 多个查询条件的传递

时间:2022-06-01 14:57:43
<!--
方法1,构建查询对象;
QueryCondition qc = new QueryCondition();
qc.setGender(1);
qc.setBirthday(new Date());
-->
<select id="selectPersonByParams" parameterType="com.stone.model.QueryCondition" resultMap="BaseResultMap">
<![CDATA[
select * from person t where t.gender=#{gender} and t.birthday <#{birthday}
]]>
</select> <!--
方法2,使用map;
map.put("gender",1);
map.put("birthday",new Date());
-->
<select id="selectPersonByParams" parameterType="java.util.Map" resultMap="BaseResultMap">
<![CDATA[
select * from person t where t.gender=#{gender} and t.birthday <#{birthday}
]]>
</select>