ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Westhveg <westhstud...@gmail.com>
Subject Retrieve inserted id in mass insert using SqlMapExecutor.
Date Thu, 09 Jul 2009 08:34:13 GMT


My environtment is:

Java 1.6
iBatis 2.3.4
Spring 2.5.6

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

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-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org

View raw message