mysql,mybatis 返回插入的主键id
<insert id="insertCompanyInfo" parameterType="com.yjf.entity.TCompanyInfo" > insert into T_Company_Info (Company_Id, IsFranchisee, Company_Code, Company_Name) values (#{companyId}, #{isfranchisee}, #{companyCode}, #{companyName}) <selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="companyId" > SELECT LAST_INSERT_ID() AS ID </selectKey> </insert>
在执行插入之后执行,查询到 主键id
SELECT LAST_INSERT_ID() AS ID
通过对象 com.yjf.entity.TCompanyInfo.companyId 取得主键
company.getCompanyId()