Mybaties保存后自动获取主键ID
<!-- 插入记录 --> <insert id="saveTvTypeBatch" useGeneratedKeys="true" keyProperty="id" parameterType="java.util.List"> <selectKey resultType="long" keyProperty="id" order="AFTER"> SELECT LAST_INSERT_ID() </selectKey> INSERT INTO T_U_TV_TYPE ( TERMINAL_TYPE , TV_TYPE_CODE , TV_TYPE_NAME , TV_TYPE_ABRIDGE_NAME , ORDER_FIELD , FLG , UPDATE_TIME ) VALUES <foreach collection="list" item="typeList" index="index" separator="," > ( #{typeList.terminalType} , #{typeList.tvTypeCode} , #{typeList.tvTypeName} , #{typeList.tvTypeAbridgeName} , #{typeList.orderField} , #{typeList.flg} , #{typeList.updateTime} ) </foreach> </insert>