ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Deepinder" <dm...@zymesolutions.com>
Subject Data insertion into Parent and Child table -- How to do this while batch insert in IBatis
Date Fri, 05 Jan 2007 14:11:24 GMT



Is it possible to insert data into a parent table and then use the generated
primary key to insert into a child table.

I need to do this during a batch insert as it is necessary(performance).


Thanking you for any lead that may be provided in solving this problem.(I
spent a day , on this problem :-))


The sample code below has a comment specifying where the problem is


public void batchInsertTable(

                                    final List beanList) {


SqlMapClientCallback() {


                                    public Object
doInSqlMapClient(SqlMapExecutor executor)

SQLException {




                                                for (int i = 0; i <
beanList.size(); i++) {

primaryKey = (Integer)executor.insert("populateTable",


                                                            //use primaryKey
for storing info in child table

//Problem is that in batch insert the primarykey value returned is random
number (not the //one in database)




                                                return null;






View raw message