在这里插入代码片
<selectid="findById"parameterType="long"resultType="com.southwind.entity.Account">
select * from t_account where id = #{id}
</select>
String 类型,通过 name 查询 Account
<selectid="findByName"parameterType="java.lang.String"resultType="com.southwind.entity.Account">
select * from t_account where username = #{username}
</select>
包装类,通过 id 查询 Account
<selectid="findById2"parameterType="java.lang.Long"resultType="com.southwind.entity.Account">
select * from t_account where id = #{id}
</select>
多个参数,通过 name 和 age 查询 Account
<selectid="findByNameAndAge"resultType="com.southwind.entity.Account">
select * from t_account where username = #{arg0} and age = #{arg1}
</select>
Java Bean
<updateid="update"parameterType="com.southwind.entity.Account">
update t_account set username = #{username},password = #{password},age =#{age} where id = #{id}
</update>
3.resultType:结果类型
基本数据类型,统计 Account 总数
<selectid="count"resultType="int">
select count(id) from t_account
</select>
包装类,统计 Account 总数
<selectid="count2"resultType="java.lang.Integer">
select count(id) from t_account
</select>
String 类型,通过 id 查询 Account 的 name
<selectid="findNameById"resultType="java.lang.String">
select username from t_account where id = #{id}
</select>
Java Bean
<selectid="findById"parameterType="long"resultType="com.southwind.entity.Account">
select * from t_account where id = #{id}
</select>
1.statement 标签:select、update、delete、insert 分别对应查询、修改、删除、添加操作。2.parameterType:参数数据类型基本数据类型,通过 id 查询 Account在这里插入代码片 <select id="findById" parameterType="long" resultType="com.southwind.entity.Account"> select * from t_account where id = #{id}