<insert id="addUser" parameterType="com.liupan.user">
         <selectKey keyProperty="id" resultType="java.lang.Integer" order="AFTER">
             select currval('user_user_id_seq') as id
         </selectKey>
         insert into USER(USER_NAME,PASSWORD,CREATE_TIME) 
         values(#{userId},#{password},#{createTime,typeHandler=dateTimeTypeHandler})
   </insert>

除了currval()函数外,还有nextval()函数,但是nextval()函数会导致postgresql的主键加1,所以不能用在这种情况下

相关文章:

  • 2022-12-23
  • 2021-08-31
  • 2022-12-23
  • 2022-12-23
  • 2022-03-01
  • 2022-12-23
  • 2022-12-23
  • 2022-01-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-04-09
  • 2022-12-23
  • 2022-12-23
  • 2021-08-17
相关资源
相似解决方案