Mybatis注解开发 @Select @Insert @Update @Delete

Mybatis注解开发 @Select @Insert @Update @Delete

@Select用法

如果未使用mybatis的动态标签,则不需要加标签
注意若数据库为在oracle,使用容易造成字段类型不匹配的问题
@Mapper
public interface RtcCheckParamBussDao {
    @Select(value = "")
    int checkUserBranch(@Param(value = "branchCode" ) String branchCode, @Param(value = "subBranchCode" )String subBranchCode,@Param(value = "userId" ) String userId);

    @Select(value = "")
    int checkAccountContract(@Param(value = "account_no") String account_no,@Param(value = "contract_no") String contract_no);

    @Select(value = "")
    int checkProductSubProduct(@Param(value = "branchCode")String branchCode, @Param(value = "subBranchCode")String subBranchCode, @Param(value = "product")String product, @Param(value = "subProduct")String subProduct);

    @Select(value = "")
    int checkTillDepartmentCurrency(@Param(value = "branchCode")String branchCode, @Param(value = "subBranchCode")String subBranchCode, @Param(value = "department")String department, @Param(value = "tillCode")String tillCode,@Param(value = "currency") String currency);

    @Select(value = "")
    int checkAccountNoContractNo(@Param(value = "parm01") String parm01, @Param(value = "parm02") String parm02);

    @Select(value = "")
    String checkPageVerify(Map map);
}

@Update使用

  @Update({ "update sys_role set role_name = #{roleName},enabled = #{enabled},create_by = #{createBy},create_time = #{createTime, jdbcType=TIMESTAMP} where id = #{id}" })
    int updateSysRoleById(SysRole sysRole);

@Insert使用

// 批量插入数据
@Insert("")
void addBatch(@Param("Lines") List Lines);

@Delete使用

@Delete("delete from sys_role where id = #{id}")
    int deleteSysRoleById(Long id);

你可能感兴趣的:(数据库,mysql,mybatis,mysql,mybatis,数据库,oracle)