RE: problems with batch-mode=trueSeems it works for me when I tried
following

1) batch-mode="true" in repository

2) start transaction before setting the batch mode

    broker.beginTransaction();
    broker.serviceConnectionManager().setBatchMode(true);

3) I tried this on delete. There were no exceptions and the records got
deleted. However, it did not show me any delete statement in the log even
though I set the logging to debug mode.

4) If I switch the above to the following

    broker.serviceConnectionManager().setBatchMode(true);
    broker.beginTransaction();

I got following exception

org.apache.ojb.broker.TransactionInProgressException: ConnectionManager
is already in transaction
        at
org.apache.ojb.broker.core.PersistenceBrokerImpl.beginTransaction(Unknown
Source)
        at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.beginTransaction(Unkn
own Source)
        at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.beginTransaction(Unkn
own Source)
        at
com.gsnx.ojbeval.db.GSNPersistenceBroker.delete(GSNPersistenceBroker.java:84
)
        at com.gsnx.ojbeval.db.BaseDao.delete(BaseDao.java:57)

In the log, I did see the delete statement.

My questions are:
1) Which way should I use? start transaction first or set batch mode to
"true" first?
2) How do I know it really does batch delete?
3) Is there any disadvantage if I always set it to batch mode for any
transaction?

Thanks,
Zhe


  -----Original Message-----
  From: Bonnie MacKellar [mailto:[EMAIL PROTECTED]
  Sent: Wednesday, October 22, 2003 6:02 AM
  To: OJB Users List
  Subject: RE: problems with batch-mode=true


  Hi,

  Here is the code that I tested. You can
  see that setBatchMode is called before I start
  the tx.
          try
          {
              broker.serviceConnectionManager().setBatchMode(true);
              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();
          }
          catch(Exception e)
          {
                  e.printStackTrace();
                  logger.error(e.getMessage());
                  broker.abortTransaction();
          }
          finally
          {
              broker.close();
          }

  This chunk of code, exectued with batch-mode="true"
  in repository_database.xml, results in the following
  two exceptions :

  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.util.batch.BatchConnection.commit(Unknown
Source)
          at
org.apache.ojb.broker.accesslayer.ConnectionManagerImpl.localCommit(Unknown
Source)
          at
org.apache.ojb.broker.core.PersistenceBrokerImpl.commitTransaction(Unknown
Source)
          at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.commitTransaction(Unk
nown Source)
          at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.commitTransaction(Unk
nown Source)
          at
com.mobius.activebill.dbmigrationutils.CustomerMigration.main(CustomerMigrat
ion.java:69)
  3425  ERROR [main] dbmigrationutils.CustomerMigration - object is not an
instance of declaring class
  3435  DEBUG [main] core.PersistenceBrokerImpl - PB.close was called:
[EMAIL PROTECTED]

  org.apache.ojb.broker.TransactionNotInProgressException: ConnectionManager
is NOT in transaction
          at
org.apache.ojb.broker.core.PersistenceBrokerImpl.abortTransaction(Unknown
Source)
          at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.abortTransaction(Unkn
own Source)
          at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.abortTransaction(Unkn
own Source)
          at
com.mobius.activebill.dbmigrationutils.CustomerMigration.main(CustomerMigrat
ion.java:75)
  Exception in thread "main"



  It looks like the persistence broker is being closed down before the call
to abortTransaction
  is made. But that does not explain the first exception. This code works
perfectly with
  batch-mode="false".

  And, if I call executeBatch, I don't get the second exception (the one
about not being in
  a transaction), although I still get the first transaction.

  I am including  my repository_database.xml as an attachment. It is always
possible that
  I am doing something terribly wrong there. The relevant jcd-alias is
"ActiveBillStandalone"

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




  > -----Original Message-----
  > From: Armin Waibel [mailto:[EMAIL PROTECTED]
  > Sent: Tuesday, October 21, 2003 5:37 PM
  > To: OJB Users List
  > Subject: Re: problems with batch-mode=true
  >
  >
  > Hi,
  >
  > hmm, this should not happen.
  >
  > Please try to set
  > broker.serviceConnectionManager.setBachMode(true);
  > before start the tx. Because the connection was
  > associated with PB instance on PB.beginTx, so setting
  > batch-mode after this may cause problems.
  >
  > I currently made some tests against sapDB
  > without any problems (using CVS head)
  >
  > regards,
  > Armin
  >
  >


Reply via email to