ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilles Bayon" <ibatis....@gmail.com>
Subject Re: Do not use <selectKey> with SCOPE_IDENTITY and MSSQL?
Date Tue, 18 Sep 2007 16:47:57 GMT
You already have all at your finger, sample

            Category category = new Category();
            category.Name = "toto";
            category.Guid = Guid.NewGuid();

            sqlMap.QueryForObject("InsertCategoryScope", category,
category);
with
    <resultMap id="resultMapScope" class="Category">
      <result property="Id" column="Category_ID"/>
    </resultMap>

    <statement id="InsertCategoryScope" parameterClass="Category"
resultMap="resultMapScope">
      insert into Categories
      (Category_Name, Category_Guid)
      values
      (#Name#, #Guid:UniqueIdentifier#);
      select SCOPE_IDENTITY() as Category_ID
    </statement>


-- 
Cheers,
Gilles

<a href="http://www.amazon.com/gp/registry/6JCP7AORB0LE">Wish List</a>

Mime
View raw message