ibatis 插入数据返回主键写法

  <insert id="USER_INFO.insertSelective" parameterClass="com.model.UserInfo" >
    
<selectKey resultClass="java.lang.Long" keyProperty="uiId">
SELECT USER_INFO_SEQ.nextval AS CAD_ID FROM DUAL
  </selectKey>
      insert into USER_INFO
      <dynamic prepend="(" >
        <isNotNull prepend="," property="uiId" >
          UI_ID
        </isNotNull>
        <isNotNull prepend="," property="mobile" >
          MOBILE
        </isNotNull>
        <isNotNull prepend="," property="password" >
          PASSWORD
        </isNotNull>
        <isNotNull prepend="," property="state" >
          STATE
        </isNotNull>
        <isNotNull prepend="," property="question" >
          QUESTION
        </isNotNull>
        <isNotNull prepend="," property="answer" >
          ANSWER
        </isNotNull>
        <isNotNull prepend="," property="createTime" >
          CREATE_TIME
        </isNotNull>
        <isNotNull prepend="," property="updateTime" >
          UPDATE_TIME
        </isNotNull>
        <isNotNull prepend="," property="demo" >
          DEMO
        </isNotNull>
        )
      </dynamic>
      values
      <dynamic prepend="(" >
        <isNotNull prepend="," property="uiId" >
          <![CDATA[ #uiId# ]]>
        </isNotNull>
        <isNotNull prepend="," property="mobile" >
          <![CDATA[ #mobile# ]]>
        </isNotNull>
        <isNotNull prepend="," property="password" >
          <![CDATA[ #password# ]]>
        </isNotNull>
        <isNotNull prepend="," property="state" >
          <![CDATA[ #state# ]]>
        </isNotNull>
        <isNotNull prepend="," property="question" >
          <![CDATA[ #question# ]]>
        </isNotNull>
        <isNotNull prepend="," property="answer" >
          <![CDATA[ #answer# ]]>
        </isNotNull>
        <isNotNull prepend="," property="createTime" >
          <![CDATA[ #createTime# ]]>
        </isNotNull>
        <isNotNull prepend="," property="updateTime" >
          <![CDATA[ #updateTime# ]]>
        </isNotNull>
        <isNotNull prepend="," property="demo" >
          <![CDATA[ #demo# ]]>
        </isNotNull>
        )
      </dynamic>
    </insert>

猜你喜欢

转载自haidaoqi3630.iteye.com/blog/1934523