ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tony Selke" <tony.se...@gmail.com>
Subject RE: Do not use <selectKey> with SCOPE_IDENTITY and MSSQL?
Date Tue, 18 Sep 2007 17:13:30 GMT
You are absolutely correct and that is exactly what I described as our
work-around.  However, we should be able to use the <insert> tag as it was
intended and not need to fall back to the <statement> tag to work around it.
I am not suggesting that there isn't a way to do it, only that the mechanism
that used to work (<insert> tags with @@IDENTITY) should be on the list of
things to update to use the current mechanism (SCOPE_IDENTITY()).

 

Tony

 

 

From: Gilles Bayon [mailto:ibatis.net@gmail.com] 
Sent: Tuesday, September 18, 2007 12:48 PM
To: user-cs@ibatis.apache.org; Tony Selke
Subject: Re: Do not use <selectKey> with SCOPE_IDENTITY and MSSQL?

 

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>
http://www.amazon.com/gp/registry/6JCP7AORB0LE">Wish List</a> 


Mime
View raw message