一.插入时同时返回回自增长的的主键
<insert id="insert" parameterType="com.pinyougou.pojo.TbSpecification" >
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="id">
SELECT LAST_INSERT_ID() AS id
</selectKey>
insert into tb_specification (id, spec_name)
values (#{id,jdbcType=BIGINT}, #{specName,jdbcType=VARCHAR})
</insert>
他会把主键保存在插入时那个对象里面
二.查询时把字段名换成我们想要的字段名(如果不想封装到实体,就在resultType配置map即可)
<select id="selectOptionList" resultType="java.util.Map" >
select id,name as text from tb_brand
</select>