ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oleksa borodie <oleksa.boro...@gmail.com>
Subject Re: auto-key generation example
Date Tue, 25 Oct 2005 06:03:03 GMT
> If possible, please provide an example where an insert statement returns the
> new key.

 I could provide an example for MS SQL assigning new key value to the
object property.
You should add selectKey element to the insert element as follows:
<selectKey resultClass="int" type="post" property="ID">
 SELECT cast(IDENT_CURRENT('dbo.TableName') as int) AS ID
</selectKey>
where "ID" - object property to hold key value and "TableName" - table
name with key identity.
 When insert statement will be executed selectKey will assign new
identity value to the object property.

PS Why there are so many empty lines in your message? Or it's GMail bug?

Mime
View raw message