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
Yes,

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

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)
  VALUES
  <iterate property="fruits" conjunction=",">
    (#fruits[].id#, #fruits[].name#)
  </iterate>
</insert>



		
__________________________________ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com

Mime
View raw message