ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Härtel, Eric <E.Haer...@d-trust.net>
Subject getting auto-generated key
Date Thu, 01 Nov 2007 15:14:05 GMT
Hello list,

I have "Person" class with several phone numbers (0-*) I have the numbers in a separate table
with two columns, persId and number. When I insert the person I want to insert the phone numbers,
too. So I wrote:

<insert id="insertPerson" parameterClass="Person">
	INSERT INTO Person ( salutation, degree, firstname, ) 
		VALUES ( #salutation:VARCHAR#, #degree:VARCHAR#, #firstname:VARCHAR# );
	<selectKey resultClass="int" >
		SELECT @@IDENTITY AS ID
	</selectKey>
	<iterate property="telefonNrs" conjunction="; ">
		INSERT INTO phoneNumbers (persId, number)
		VALUES ( id, #telefonNrs[]# )
	</iterate>
</insert>

The problem is: I need the auto-generated person key to insert the phone numbers. How can
I get?

Greetings Eric

Mime
View raw message