ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "lali m" <m.alal...@gmail.com>
Subject Ibatis : multiple insert
Date Mon, 25 Aug 2008 00:43:20 GMT
hi,

I have to do multiple insert in same time and for the moment I not found how
do it.
exemple : for one student I have to do insert all books

Student student {
Sring name
.................


List<Book> bookList;

}

(studentTable ) 1---------------------- n(bookTable)

whene I insert a student I need to insert (0 or n) books
I need to do some things like that :


<insert id="InsertSudent" parameterClass="AnnonceDaoLine" >

insert into students (id, name,date, ..... ) values (?,?,?,....)

<selectKey resultClass="int" keyProperty="id" type="post">

SELECT @@IDENTITY AS id_student

</selectKey>

</insert>

<insert id="insertBooks" parameterClass="BookInfoLines">

insert into books (id, tilte, ......)

<iterate property="bookList" >

values (#id#, #tilte#, ....)

</iterate>

where id=#id_student#

</insert>

Mime
View raw message