Mybatis注解

一,@Select注解

   @Select("select * from  smbms_user")
    public List<IUser>  getAllUser();

  

二,@Select和@Results注解的联用

@Results(id="userMapper",value={
            @Result(property="id",column="id",id=true),
            @Result(property="userName",column="userName"),

    })
    @Select("select * from  smbms_user")
    public List<IUser>  getAllUser();

@ResultMap("userMapper")//引入@Results定义的resultMap
    @Select("select * from user")
    List<Student> getAll();
}

  

  

三,@Insert注解

 @Insert("INSERT INTO  smbms_user(userCode,userName,userPassword)\n" +
            "        VALUES (#{userCode},#{userName},#{userPassword})")
    public int addUser(IUser user);

  

四,@Update注解

 @Update("update smbms_user set userCode=#{userCode} where id=#{id}")
    public int updateUser(IUser user);

  

五,@Delete

 @Delete(" delete from  smbms_user where id=#{id}")
    public int deleteUser(int id);

  

 

上一篇:smbms系统项目的密码修改模块


下一篇:企图掌握最小生成树和二分图