ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tsolak Barseghyan <tsolakbarsegh...@yahoo.com>
Subject Auto_Increment MySQL
Date Thu, 13 Oct 2005 19:34:09 GMT

Hi, I’m beginner with iBatis and want to know how to insert into MySQL database  table a
row which primary key is ‘Auto_Increment’   type and I want to be returned the id of my
table like in this examples from “iBATIS Developer Guide”.

 

 

<!—Oracle SEQUENCE Example -->

<insert id="insertProduct-ORACLE" parameterClass="com.domain.Product">

<selectKey resultClass="int" >

SELECT STOCKIDSEQUENCE.NEXTVAL AS ID FROM DUAL

</selectKey>

insert into PRODUCT (PRD_ID,PRD_DESCRIPTION)

values (#id#,#description#)

</insert>

<!— Microsoft SQL Server IDENTITY Column Example -->

<insert id="insertProduct-MS-SQL" parameterClass="com.domain.Product">

insert into PRODUCT (PRD_DESCRIPTION)

values (#description#)

<selectKey resultClass="int" >

SELECT @@IDENTITY AS ID

</selectKey>

</insert>


		
---------------------------------
 Yahoo! Music Unlimited - Access over 1 million songs. Try it free.
Mime
View raw message