zoukankan      html  css  js  c++  java
  • Spring Boot中mybatis insert 如何获得自增id

    https://www.cnblogs.com/quan-coder/p/8728410.html

    注意要显式设置主键,通过:

    @Options(useGeneratedKeys = true, keyProperty = "id")
    

    将id设置为主键返回。

    https://blog.csdn.net/suwu150/article/details/52896496

    一个示例(Mapper中的代码片段):

    	@Insert("insert into tz_lawsuits " + 
    			"(credit_cooperative, change_date, admin, borrower, borrower_id, guarantee, litigation_principal, type, starting_end_date," + 
    			" lawyer, action_date, litigation_costs, attorney_fees, advance, verdict_id, implementation_date, award_id, takeback_agent_fee," + 
    			" takeback_litigation_costs, takeback_principal, outstanding_principal, responsible_person)" + 
    			" values" + 
    			"(#{credit_cooperative}, #{change_date}, #{admin}, #{borrower}, #{borrower_id}, #{guarantee}, #{litigation_principal}, #{type}, #{starting_end_date}," + 
    			" #{lawyer}, #{action_date}, #{litigation_costs}, #{attorney_fees}, #{advance}, #{verdict_id}, #{implementation_date}, #{award_id}, #{takeback_agent_fee}," + 
    			" #{takeback_litigation_costs}, #{takeback_principal}, #{outstanding_principal}, #{responsible_person})")
    	@Options(useGeneratedKeys = true, keyProperty = "id")
    	Integer insertTzLawsuitsObject(TzLawsuits tzLawsuits);
    
  • 相关阅读:
    两种方法生成随机字符串
    cmd命令总结
    NOI前乱写
    多校模拟9
    字符串 口胡
    HEOI2020游记
    省选模拟104
    省选模拟103
    省选模拟102
    省选模拟101
  • 原文地址:https://www.cnblogs.com/zifeiy/p/9760500.html
Copyright © 2011-2022 走看看