Put the name of the property that hold the ID in the sql map and the record get's updated with the id and your insert statement returns the id object
Here is MS SQl example, just replace SELECT @@IDENTITY with the correct query for Mysql to fetch the ID <insert id="ibatorgenerated_insert" parameterClass=".." > <!-- WARNING - This element is automatically generated by Apache iBATIS ibator, do not modify. This element was generated on Fri Mar 06 08:29:29 GMT 2009. --> insert into online_upload_log (id, userid, actmonth, basemonth, datestamp, result) values (#uploadLogId:INTEGER#, #userid:INTEGER#, #actmonth:INTEGER#, #basemonth:BIT#, #datestamp:TIMESTAMP#, #result:LONGVARCHAR#) <selectKey resultClass="java.lang.Integer" keyProperty="uploadLogId" > SELECT @@IDENTITY </selectKey> </insert> Meindert -----Original Message----- From: Westhveg [mailto:westhstud...@gmail.com] Sent: 09 July 2009 10:34 AM To: user-java@ibatis.apache.org Subject: Retrieve inserted id in mass insert using SqlMapExecutor. Hello, My environtment is: Java 1.6 iBatis 2.3.4 Spring 2.5.6 MySQL I've a method to create records massively (I write directly, it can has sintax errors; just take the idea): public List<T> createRecordsMassively(final List<T> records) { getSqlMapClientTemplate().execute(new SqlMapClientCallback() { public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException { executor.startBatch(); for (T record : records) { executor.insert("insertRecord", record); } //List<BatchResult> result = executor.executeBatchDetailed(); int rowsAffected = executor.executeBatch(); return new Integer(rowsAffected); } }); /*Deal with result*/ } It works well. The problem is: I want to know which records are correctly inserted and which aren't. I need the Id in order to execute some logic with each inserted record. ¿What's the way? ¿How can I retrieve the id of the inserted records? Thanks in advance, Westhveg -- View this message in context: http://www.nabble.com/Retrieve-inserted-id-in-mass-insert-using-SqlMapExecutor.-tp24406261p24406261.html Sent from the iBATIS - User - Java mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org For additional commands, e-mail: user-java-h...@ibatis.apache.org Checked by AVG - www.avg.com Version: 8.5.375 / Virus Database: 270.13.8/2223 - Release Date: 07/08/09 21:51:00 --------------------------------------------------------------------- To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org For additional commands, e-mail: user-java-h...@ibatis.apache.org