在使用mybatis + postgresql,我们有时在插入数据时需要返回自增id的值,此时在插入时,可以按照以下例子来编写mapper文件

<insert >
    <selectKey resultType="int"  order="AFTER" keyProperty="pid" >
        SELECT currval('tbl_user_pid_seq'::regclass) AS pid
    </selectKey>
    insert into tbl_user(name, age) values(#{name}, #{age})
</insert>

  

相关文章:

  • 2022-12-23
  • 2022-02-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-01
  • 2021-10-29
  • 2022-12-23
  • 2022-12-23
  • 2021-06-06
相关资源
相似解决方案