ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Benedict <paul4chris...@yahoo.com>
Subject Re: Bulk inserts
Date Thu, 03 Nov 2005 07:44:12 GMT

SQL has a notation to INSERT multiple entries at once.
What you want to do is build a statement like the

INSERT INTO fruit (id, name) VALUES (0, 'Pear'), (1,
'Apple'), (2, 'Peach')

Use the <iterate> tag to build the dynamic list at the
end. In this example, the GroceryBag object has a
property of Fruit[] called fruits:

<insert id="insertFruit" parameterClass="GroceryBag">
  INSERT INTO fruit 
    (id, name)
  <iterate property="fruits" conjunction=",">
    (#fruits[].id#, #fruits[].name#)

Yahoo! FareChase: Search multiple travel sites in one click.

View raw message