<select id="selectUserById2" parameterType="int" resultMap="resultMap">
select * from user where id=#{id};</select><resultMap id="resultMap" type="user"><result column="pwd" property="password"/></resultMap>
@Select("select * from user where id=#{uid} and name=#{name}")//使用常见数据类型, 和String类型必须使用@Param给定别名
User selectOne(@Param("uid")int id,@Param("name") String name);@Update("update user set pwd=#{newPwd} where id=#{id}")intupdate(@Param("id")int id,@Param("newPwd") String newPWd);@Insert("insert into user values(#{id}, #{name}, #{pwd})")intinsert(User user);@Delete("delete from user where id=#{id}")intdelete(@Param("id")int id);
文章目录使用万能的ResultMap解决属性名和字段名不一致问题解决方法使用ResultMap时间分页查询实现分页RowBounds实现分页使用注解实现简单的CRUD实现注意@Param的使用使用万能的ResultMap解决属性名和字段名不一致问题属性名和字段名不一致就是java中实体类的属性名称和数据库中的字段名称不一致就会造成查到实体类所对应的字段为null解决方法在sql语句中进行 字段名改造使用resultMap将属名与字段名进行匹配 <select i