博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Mybatis注解开发 @Select @Insert @Update @Delete
阅读量:198 次
发布时间:2019-02-28

本文共 1645 字,大约阅读时间需要 5 分钟。

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

@Select用法

如果未使用mybatis的动态标签,则不需要加标签注意若数据库为在oracle,使用容易造成字段类型不匹配的问题
@Mapperpublic 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);

转载地址:http://fkji.baihongyu.com/

你可能感兴趣的文章