xml的sql语句写法
记得加上useGeneratedKeys和keyProperty配置即可,前者是指设置是否使用jdbc的getGenereatedKeys方法获取主键并赋值到keyProperty设置的属性中,后者即实体类主键字段(并且大小写要对应上)
<insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="StMobileContent"> name, sex ) VALUES ( #{name}, #{sex} ) </insert>