insert 返回主键id
在insert语句中写入useGeneratedKeys="true" keyProperty="configId"
configId 指的是AdConfigureCondition对象的主键字段
<insert id="insert" parameterType="com.shihou.module.ad.domain.AdConfigureCondition" useGeneratedKeys="true" keyProperty="configId">
insert into ad_configure (on_page, ad_type,
title, start_time, end_time,
client_type, show_type, content_type,
content_url, jump, status,
seconds, time_rule, create_time,
show_position, ids)
values (#{onPage,jdbcType=VARCHAR}, #{adType,jdbcType=VARCHAR},
#{title,jdbcType=VARCHAR}, #{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP},
#{clientType,jdbcType=VARCHAR}, #{showType,jdbcType=VARCHAR}, #{contentType,jdbcType=VARCHAR},
#{contentUrl,jdbcType=VARCHAR}, #{jump,jdbcType=VARCHAR}, #{status,jdbcType=BIT},
#{seconds,jdbcType=INTEGER}, #{timeRule,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{showPosition,jdbcType=VARCHAR}, #{ids,jdbcType=LONGVARCHAR})
</insert>
service中取值
@Override
public Long insertRequired(AdConfigure record) {
volid(record);
adConfigureDao.insert(record);
return record.getConfigId();
}