栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

MyBatis: 通过注解中写入数据并从数据库获得自增主键、动态SQL写入List类型的数据、动态SQL查询数据

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

MyBatis: 通过注解中写入数据并从数据库获得自增主键、动态SQL写入List类型的数据、动态SQL查询数据

一、通过使用@Options注解,将数据库的自增字段id中的值写到eemLeader对象的id字段,之后在其他地方使用

 @Options(useGeneratedKeys = true, keyColumn = "id" , keyProperty = "id")
    @Insert("insert into eem_leader(code,dept_id,name,gender,birthday,nation,politics_status,education,hire_date,working_state," +
            "del_flag,create_by,create_time,update_by,update_time,remark) " +
            "values(#{code},#{deptId},#{name},#{gender},#{birthday},#{nation},#{politicsStatus},#{education},#{hireDate},#{workingState}," +
            "#{delFlag},#{createBy},null,null,null,remark)")
    int addLeaderBasicInfo(EemLeader eemLeader);
   

二、通过动态SQL写入List类型的数据

 @Insert("")
    int addLeaderDutyInfo(@Param("leaderId") long leaderId,@Param("eemLeaderDutyList") List eemLeaderDutyList);

三、通过动态SQL查询数据

    @Select("")
    List> getLeaderListByQueryCondition(QueryCondition queryCondition);
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/889270.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号