<insert id="createUser" parameterType="cn.User" useGeneratedKeys="true" keyProperty="userId"> INSERT INTO user(name,create_time,remark,create_user_id) VALUE(#{name,jdbcType=VARCHAR},NOW(),‘new user‘,#{createUserId}) </insert>
keyProperty为User类拥有接收主键 ID 的字段,如果dao接口通过@Param("user")注解指定了user,userId要换成user.userId
时间: 2024-10-13 16:20:22