IBatis框架 利用select @@Identity 获取新增记录ID

<insert id="InsertPurchaseEvaluations" parameterClass="PurchaseEvaluations">
            INSERT INTO PurchaseEvaluations(
            ApplyMoneyID,
            PurchaseID,
            PurchaseName,
            AddUserID,
            AddUserName,
            AddTime,
            AverageScoreValue,
            EvaluationRemark,
            PurchaseLevel,
            EvaluationType)
            VALUES(
            #ApplyMoneyID#,
            #PurchaseID#,
            #PurchaseName#,
            #AddUserID#,
            #AddUserName#,
            #AddTime#,
            #AverageScoreValue#,
            #EvaluationRemark#,
            #PurchaseLevel#,
            #EvaluationType#)
            <selectKey property="Id" resultClass="int" type="post">
            select @@Identity as Id
        </selectKey>
        </insert>

 

 

public int InsertPurchaseEvaluations(PurchaseEvaluations purchaseEvaluations)
        {
            mapper.Insert("InsertPurchaseEvaluations", purchaseEvaluations);
            return purchaseEvaluations.Id;
        }

posted @ 2013-07-16 21:29  ❀在路上❀  阅读(299)  评论(0编辑  收藏  举报