<insert id="insert" parameterType="resource"> <selectKey resultType="long" order="BEFORE" keyProperty="id"> SELECT sys_resource_id_SEQ.NEXTVAL AS id FROM DUAL </selectKey> INSERT INTO <include refid="t_sys_resource"/> (id, name, type, url, permission, parent_id, parent_ids, available) VALUES (#{id}, #{name}, #{type}, #{url}, #{permission}, #{parentId}, #{parentIds}, #{available}) </insert>
使用序列sequence,进行主键自增长
CREATE SEQUENCE "PORTX"."SYS_ORGANIZATION_ID_SEQ" MINVALUE 1 MAXVALUE 999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE ;