IBatisNet Insert返回主键ID

MS SqlServer:

IBatisNet Insert返回主键ID
 1 <insert id="Insert" parameterClass="Person"> 
 2    insert into PERSON 
 3     (PER_FIRST_NAME, PER_LAST_NAME, 
 4     PER_BIRTH_DATE, PER_WEIGHT_KG, PER_HEIGHT_M) 
 5    values 
 6     ( #FirstName#, #LastName#, 
 7     #BirthDate#, #WeightInKilograms#, #HeightInMeters#) 
 8    <selectKey property="Id" type="post" resultClass="int">  
 9    select CAST(@@IDENTITY as int) as value 
10    </selectKey>  
11   </insert>
IBatisNet Insert返回主键ID

 

MySql:

IBatisNet Insert返回主键ID
 1 <insert id="Insert" parameterClass="Person"> 
 2    insert into PERSON 
 3      (PER_FIRST_NAME, PER_LAST_NAME, 
 4      PER_BIRTH_DATE, PER_WEIGHT_KG, PER_HEIGHT_M) 
 5      values 
 6       ( #FirstName#, #LastName#, 
 7      #BirthDate#, #WeightInKilograms#, #HeightInMeters#) 
 8      <selectKey property="Id" type="post" resultClass="int">  
 9      select @@IDENTITY as value 
10     </selectKey>  
11 </insert>
IBatisNet Insert返回主键ID

 

IBatisNet Insert返回主键ID,布布扣,bubuko.com

IBatisNet Insert返回主键ID

上一篇:JSONObject与JSONArray的使用


下一篇:自制MVC框架原理介绍