1、Oracle数据库中创建自增序列
create sequence local_storage_id_seq minvalue 1 nomaxvalue start with 1 increment by 1;
2、mybatis的mapper.xml中
selectKey的结果会放进传参LocalStorage对象中
<insert id="insert" parameterType="com.united.apps.nams.core.entity.LocalStorage" >
<selectKey keyProperty="id" resultType="java.lang.Long" order="BEFORE">
select local_storage_id_seq.nextval from dual
</selectKey>
insert into DEV_NAMS.LOCAL_STORAGE (ID, REAL_NAME, NAME_AS,
SUFFIX, PATH, TYPE_AS,
SIZE_AS, UPDATE_TIME, UPDATE_BY,
CREATE_TIME, CREATE_BY)
values (#{id,jdbcType=DECIMAL}, #{realName,jdbcType=VARCHAR}, #{nameAs,jdbcType=VARCHAR},
#{suffix,jdbcType=VARCHAR}, #{path,jdbcType=VARCHAR}, #{typeAs,jdbcType=VARCHAR},
#{sizeAs,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=OTHER},
#{createTime,jdbcType=TIMESTAMP}, #{createBy,jdbcType=OTHER})
</insert>