工具:mybatis+pgsql
案例 – resultType=“java.lang.Integer”
dao层
Integer selectMaxAge(String sex);
sql
<select id = "selectMaxAge" resultType = "java.lang.Integer">
select max(age)
from user
where sex = #{sex}
</select>
案例 – resultType=“int”
dao层
int count(String sex);
sql
<select id = "count" "resultType="int"">
select count(1)
from user
where sex = #{sex}
</select>

本文介绍使用MyBatis框架结合PgSQL数据库进行数据操作的具体实践,包括通过DAO层实现最大年龄和计数的查询。示例展示了如何配置SQL映射文件,以及如何在Java中调用这些SQL语句。
1332

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



