This is an issue of Sql Server who set the @@IDENTITY as decimal.
So you have to cast to integer as cast(@@IDENTITY as integer).


-----Message d'origine-----
De : Alexey Boroday [mailto:[EMAIL PROTECTED] 
Envoyà : vendredi 24 dÃcembre 2004 09:09
à : ibatis-user-cs@incubator.apache.org
Objet : selectKey resultClass bug for MSSQL identity ?

Hello.

 I've found bug or not - I don't know. 
 There is id identity column in MSSQL 2000 (8.0) tables. I'd like to get
value for the inserted records and add 

<selectKey resultClass="int" type="post" property="ID"> SELECT @@IDENTITY AS
ID </selectKey> element to the insert statement in the sqlMap configuration
file.

 In runtime for each insert ProbeException was raised : "Cannot widen from
target to primitive type". I've found that propertyValue has "decimal" type
even if resultClass was set to "int" in the selectKey element. To suppress
this exception I add cast @@IDENTITY to the integer type.

<selectKey resultClass="int" type="post" property="ID"> SELECT
cast(@@IDENTITY as integer) AS ID </selectKey>

 Now all works fine. Why iBATIS doesn't convert selectKey result to the
integer type?


--     
 Ð ÑÐÐÐÐÐÐÐÐ, ÐÐÐÐÑÐÐ ÐÐÑÐÐÐÐ
 ÐÑÐÐÐ ÑÐÐÑÐÐÐÑÐÐ ÐÐ


___________________________________________________________________________

This communication is confidential and may be legally privileged. 
If you believe you are not an intended recipient, please inform the sender, 
delete the e-mail and do not copy, print or use it or disclose it to others. 
You can inform the sender by replying to this e-mail or by telephone (+380 44 
4906080).


-- 
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.296 / Virus Database: 265.6.4 - Release Date: 22/12/2004
 

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.296 / Virus Database: 265.6.4 - Release Date: 22/12/2004
 

Reply via email to