首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

iBATIS三种自动生成主键的形式

2012-10-25 
iBATIS三种自动生成主键的方式?!--?Oracle?SEQUENCE?Example?using?.NET?1.1?System.Data.OracleClient?-

iBATIS三种自动生成主键的方式

?

  1. <!--?Oracle?SEQUENCE?Example?using?.NET?1.1?System.Data.OracleClient?-->??<insert?id="insertProduct-ORACLE"?parameterClass="product">??
  2. ????<selectKey?resultClass="int"?type="pre" keyProperty="id" >??????????SELECT?STOCKIDSEQUENCE.NEXTVAL?AS?VALUE?FROM?DUAL??
  3. ????</selectKey>??????insert?into?PRODUCT?(PRD_ID,PRD_DESCRIPTION)?values?(#id#,#description#)??
  4. </insert>????
  5. <!--?Microsoft?SQL?Server?IDENTITY?Column?Example?-->??<insert?id="insertProduct-MS-SQL"?parameterClass="product">??
  6. ????insert?into?PRODUCT?(PRD_DESCRIPTION)??????values?(#description#)??
  7. ????<selectKey?resultClass="int"?type="post" keyProperty="id" >??????????select?@@IDENTITY?as?value??
  8. ????</selectKey>??</insert>??
  9. ??<!--?MySQL?Example?-->??
  10. <insert?id="insertProduct-MYSQL"?parameterClass="product">??????insert?into?PRODUCT?(PRD_DESCRIPTION)??
  11. ????values?(#description#)??????<selectKey?resultClass="int"?type="post" keyProperty="id"?>??
  12. ????????select?LAST_INSERT_ID()?as?value??????</selectKey>??
  13. </insert>

热点排行