Hi
Regarding this issue it looks like (at least as far as RC4 is concerned)
that in the doExecute method
of PreparedStatementInvocationHandler.java the following line (223) gets
invoked
((Method) _methods.get(i)).invoke(stmt, (Object[]) _params.get(i));
In my case when using batched mode, and JSQLConnect on MSSqlServer I get a
similar error to
Bonnie (java.lang.IllegalArgumentException: object is not an instance of
declaring class)
The methods returned by _methods.get(i) is
public void
org.apache.ojb.broker.platforms.PlatformDefaultImpl.addBatch(java.sql.Prepar
edStatement)
And we are trying to executed it on the statement rather than passing the
platform instance. I think the problem
Is in the if statement in that it does an == rather than a .equals() call to
determine whether we
want to call the addBatch method. Now, I do not know whether within a single
JVM that the following
Returns true
Method method1 = obj.getClass().getMethod("methodName", <args>);
Method method2 = obj.getClass().getMethod("methodName", <args>);
method1 == method2; // is this gurantee dto be true like it is for instances
of Class e.g.
Obj.getClass() == Obj.getClass() is guranteed to be true?
Regards,
Mark Rowell
-----Original Message-----
From: Bonnie MacKellar [mailto:[EMAIL PROTECTED]
Sent: 22 October 2003 14:02
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
>
>
CreditTrade Limited is regulated by the FSA. (c) CreditTrade 2002. All rights
reserved. The information and data contained in this email is provided for the
information purposes of the addressee only and should not be reproduced and/or
distributed to any other person. It is provided without any warranty whatsoever and
unless stated otherwise consists purely of indicative market prices and other
information.
Any opinion or comments expressed or assumption made in association with the data or
information provided in this email is a reflection of CreditTrades judgement at the
time of compiling the data and is subject to change. CreditTrade hereby makes no
representation and accepts no responsibility or liability as to the completeness or
accuracy of this email.
The content of this email is not intended as an offer or solicitation for, or
recommendation of, the purchase or sale of any financial instrument, or as an official
confirmation of any transaction, and should not be construed as investment advice.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]