insert元素的id自动增加

使用selectKey元素(标准用法使用selectKey)

<insert id="createCustomer" parameterClass="map">
			<selectKey resultClass="java.lang.Integer" keyProperty="CUST_ID">
				<![CDATA[SELECT SEQ_CUST_CUSTOMER.NEXTVAL AS CUST_ID FROM DUAL ]]>
			</selectKey>
			<![CDATA[
				INSERT INTO TEST_CUST_CUSTOMER(
					CUST_ID,
					CUST_CODE,
					CUST_NAME,
					CUST_FLAG,
					CUST_DIF,
					CUST_PROP1,
					CUST_PROP2,
					CUST_TYPE,
					IDCARD_TYPE
				) values (
				 	#CUST_ID#,
					#CUST_CODE#,
					#CUST_NAME#,
					#CUST_FLAG#,
					#CUST_DIF#,
					#CUST_PROP1#,
					#CUST_PROP2#,
					#CUST_TYPE#,
					#IDCARD_TYPE#,
					
				)
			]]>
		</insert>

 直接使用seq_t_dept_department.nextval(不标准)

<insert id="create" parameterClass="map">
			insert into test_dept_department(id,dept_name,dept_code,memo,parent_id,create_date,DECP_ID,status)
			values(seq_t_dept_department.nextval,#deptName#,#deptCode#,#memo#,0,sysdate,#id#,0)
		</insert>

猜你喜欢

转载自liuna718-163-com.iteye.com/blog/2209071