XML
<insert id="insert" parameterType="com.stone.model.Person"> <!-- selectKey 是做主键返回的 keyProperty 接受返回主键的属性 order: insert语句和生成主键的sql执行顺序;mysql是AFTER,在oracle中是BEFORE resultType:返回主键的数据类型 生成主键的sql: select LAST_INSERT_ID() --> <selectKey keyProperty="personId" order="AFTER" resultType="java.lang.Integer"> select LAST_INSERT_ID() </selectKey insert into person(name,gender,addr,birthday) values(#{name},#{gender},#{addr},#{birthday}) </insert>
时间: 2024-10-16 19:18:13