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.doExecut
e(Unknown Source)
        at
org.apache.ojb.broker.util.batch.PreparedStatementInvocationHandler.invoke(U
nknown 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(Unknown
Source)
        at
com.mobius.activebill.dbmigrationutils.CustomerMigration.main(CustomerMigrat
ion.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(Unknown
Source)
        at
com.mobius.activebill.dbmigrationutils.CustomerMigration.main(CustomerMigrat
ion.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