MySql和SqlServer 支持主键自增长的数据库:
<insert id="add" parameterType="com.yweb.entity.User" keyProperty="id" useGeneratedKeys="true">
insert into (name,age) values ('zs',18)
</insert>
Oracle不支持主键自增长的数据库:
<insert id="AltName.insert" parameterType="AltName">
<selectKey resultType="long" keyProperty="id">
SELECT SEQ_TEST.NEXTVAL FROM DUAL
</selectKey>
insert into altname(primaryName,alternateName,type)values(#{primaryName},#{alternateName},#{type})
</insert>