Hello Pablo,

 

Your code snippet works well.

 

Much thanks!

 

Regards,

Gary Russo

 

 


Gary P. Russo
Wolters Kluwer - Corporate Legal Services
111 Eighth Avenue
New York, NY 10011

Blog:     http://spaces.msn.com/members/pocketxp/

MSN IM: [EMAIL PROTECTED]

email:   [EMAIL PROTECTED]
url:       http://www.ctadvantage.com


From: Pablo López [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 25, 2005 3:23 AM
To: [email protected]
Subject: RE: auto-key generation example

 

Hi Gary,

 

Have a look at my map, it’s working for me. Sorry it’s in Spanish. I didn’t look at your code deeply enough but I guess that you need to retrieve the id BEFORE you insert the user (in SQL Server) and select it as VALUE, so you can return it back.

 

 

      <insert id="InsertarUsuario" parameterClass="Usuario">

 

            <selectKey property="IdUsuario" resultClass="int">

                SELECT cast(@@IDENTITY as int) as value

            </selectKey>

 

            INSERT INTO usuarios (dni, nombre, apellido1, apellido2,

                              telefono1, telefono2, email, fotografia,

                              vehiculo, matricula, plaza)

            VALUES (#Dni#, #Nombre#, #Apellido1#, #Apellido2#,

                  #Telefono1#, #Telefono2#, #Email#, #Fotografia#,

                  #Vehiculo#, #Matricula#, #Plaza#)

 

      </insert>

 

In case you need further info just, just ask again J

 

See you,

 

Pablo.

Reply via email to