> However, I decided to use Pablo's code because there is no hard coded
> table name.

 I don't like it - but it is placed near main insert statement where
table name is hardcoded too.

> <selectKey property="IdUsuario" resultClass="int">
>  SELECT cast(@@IDENTITY as int) as value
> </selectKey>

 Use it with carefull - in case of multipile inserts you could get
wrong @@IDENTITY value.

 E.g.
 1. application1 inserts record to the Table1 (using iBATIS)
 2. application2 inserts record to the Table2 (using anything to
access database)
 3. selectKey performed for the app1 insert ATTENTION!
 4. selectKeyPerformed for the app2 insert

 If thing goes as in the example above you'll get wrong ID for
inserted object in the app1.

Good luck.

Reply via email to