首页 > Web开发 > 详细

IBatisNet Insert返回主键ID

时间:2014-05-29 14:23:39      阅读:447      评论:0      收藏:0      [点我收藏+]

MS SqlServer:

bubuko.com,布布扣
 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>
bubuko.com,布布扣

 

MySql:

bubuko.com,布布扣
 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>
bubuko.com,布布扣

 

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

IBatisNet Insert返回主键ID

原文:http://www.cnblogs.com/fb-boy/p/3757097.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!