mybatis的insert返回主键

  1. <insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="com.model.OperationBookList" >
  2. insert into operation_book_list (id, name, introduce,
  3. category, state, up_date,
  4. stop_date, down_date, modify_date
  5. )
  6. values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{introduce,jdbcType=VARCHAR},
  7. #{category,jdbcType=VARCHAR}, #{state,jdbcType=CHAR}, #{upDate,jdbcType=TIMESTAMP},
  8. #{stopDate,jdbcType=TIMESTAMP}, #{downDate,jdbcType=TIMESTAMP}, #{modifyDate,jdbcType=TIMESTAMP}
  9. )
  10. </insert>

 在insert属性里增加useGeneratedKeys="true" keyProperty="id"

上一篇:ubuntu14.04 64位安装 g2o


下一篇:MyBatis insert返回主键(sqlserver2008)