方式一:
xml文件写法
<!-- user.xml -->
<select id="selectUsersByCondition" parameterClass="java.util.HashMap" resultMap="UserResult">
<![CDATA[
select
ID as id,
NAME as name,
AGE as age
from
t_user
where id < #id# and age < #age#
]]>
</select>
java代码写法HashMap<String, Object> map = new HashMap<String, Object>();
map.put("id", 5);
map.put("age", 24);
List list = sqlMapper.queryForList("selectUsersByCondition", map);
XML文件与Java代码整合示例
本文展示了如何使用XML文件定义SQL查询条件,并通过Java代码实现查询功能,结合了数据库配置灵活性与代码的可读性。
202

被折叠的 条评论
为什么被折叠?



