Here is a repost of my original problem with batch mode, just in case
someone sees it and has a good idea. I  don't know if I am just coding
this wrong, or if there is a more serious problem. This is a major problem
since we need to migrate a lot of records into a database, and would
like to do it in batch mode.

thanks
Bonnie MacKellar
software engineer
Mobius Management Systems, Inc.
[EMAIL PROTECTED]

>  -----Original Message-----
> From:         Bonnie MacKellar  
> Sent: Monday, October 20, 2003 11:42 AM
> To:   OJB Users List (E-mail)
> Subject:      problems with batch-mode=true
> 
> I am trying to insert records in batch mode. Perhaps I don't understand
> how this
> works. Here is my test code to insert 100 customers :
> 
>         ConnectionManagerIF conMan = broker.serviceConnectionManager();
>         try
>         {
>             broker.beginTransaction();
> 
>             for (int i = 0; i < 100; i++)
>             {
> 
>                 CustomerInterface customer = new Customer();
>                 customer.setCustomerNumber("100" + i);
>                 customer.setFirstName("Big");
>                 customer.setLastName("Customer");
>                 customer.setCustomerName("BadCorporation");
>                 customer.setDeleteTag(Boolean.FALSE);
> 
>                 broker.store(customer);
>             }
> 
>             conMan.executeBatch();
>             broker.commitTransaction();
>               }
> 
> When I run this with batch-mode="false", it works perfectly, although it
> generates a SELECT and a
> DELETE for every INSERT (which seems rather inefficient). I imagine this
> has something to do with
> an M:N nondecomposed relationship which involves Customer records.
> 
> When I run this with batch-mode="true", it fails. I get the following
> exception
> java.lang.IllegalArgumentException: object is not an instance of declaring
> class
>       at java.lang.reflect.Method.invoke(Native Method)
>       at
> org.apache.ojb.broker.util.batch.PreparedStatementInvocationHandler.doExec
> ute(Unknown Source)
>       at
> org.apache.ojb.broker.util.batch.PreparedStatementInvocationHandler.invoke
> (Unknown Source)
>       at $Proxy0.doExecute(Unknown Source)
>       at
> org.apache.ojb.broker.util.batch.BatchConnection.executeBatch(Unknown
> Source)
>       at
> org.apache.ojb.broker.accesslayer.ConnectionManagerImpl.executeBatch(Unkno
> wn Source)
>       at
> com.mobius.activebill.dbmigrationutils.CustomerMigration.main(CustomerMigr
> ation.java:68)
> rethrown as org.apache.ojb.broker.accesslayer.OJBBatchUpdateException:
> object is not an instance of declaring class
>       at
> org.apache.ojb.broker.accesslayer.ConnectionManagerImpl.executeBatch(Unkno
> wn Source)
>       at
> com.mobius.activebill.dbmigrationutils.CustomerMigration.main(CustomerMigr
> ation.java:68)
> when conMan.executeBatch() is called.
> 
> Am I doing something wrong here? I am using rc4, with MSSqlServer and
> JSQLConnect.
> 
> thanks,
> Bonnie MacKellar

Reply via email to