1. 程式人生 > 實用技巧 >oracle 自增序列 在 mybatis中應用

oracle 自增序列 在 mybatis中應用

建立自增序列:
create sequence SEQ_INCREMENT_LOG

increment by 1
start with 1 
minvalue 1
maxvalue 999999999;

查詢oracle自增序列:

select SEQUENCE_OWNER,SEQUENCE_NAME from dba_sequences where sequence_owner='PPNIE';

xml片段:

  <insert id="insert" parameterType="cn.com.soft.domain.IncrementLog">
    <selectKey 
keyProperty="id" order="BEFORE" resultType="long"> select SEQ_INCREMENT_LOG.NEXTVAL as id from dual </selectKey> insert into INCREMENT_LOG (ID, NAME, OPERAT_TM, OPERAT_TYPE, DATA_TOTAL, DATE_TM, SUCCESS_FLAG, NOTE, DATA_FILE_NAME, MAPPING_FILE_NAME, OPERAT_START, OPERAT_END ) values (#{id,jdbcType=DECIMAL}, #{name,jdbcType=VARCHAR}, #{operatTm,jdbcType=TIMESTAMP}, #{operatType,jdbcType=VARCHAR}, #{dataTotal,jdbcType=DECIMAL}, #{dateTm,jdbcType=TIMESTAMP}, #{successFlag,jdbcType=VARCHAR}, #{note,jdbcType=VARCHAR}, #{dataFileName,jdbcType=VARCHAR}, #{mappingFileName,jdbcType=VARCHAR}, #{operatStart,jdbcType=TIMESTAMP}, #{operatEnd,jdbcType=TIMESTAMP} )
</insert>