Mike
Edson Carlos Ericksson Richter wrote:
Excuse, as I have read one mail after yours, I don't fixed in the fact that you are using ODMG. I've sen't my sample based on PB Api.
I've tried ODMG before, but was to poor (or I don't know how to manage things with it) for my applications...
Well, I'll research some (if I get some time to do it). Perhaps, someone else should had this problem with ODMG...
Best regards,
Edson Richter
Em Ter, 2003-07-15 �s 13:24, Dave Hodson escreveu:
I'm using the ODMG transactional handler. My understanding is that the PB API is called internally so I have no explicit PB calls in my Put method
Is my understanding of ODMG correct? (I'm basing this on Tutorial #2)
Dave
-----Original Message----- From: Edson Carlos Ericksson Richter [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 15, 2003 6:13 AM To: OJB Users List Subject: RE: ConnectionManager is already in transaction
I had this problem in the past, and what I had to do is change my code to something like (this is a delete sample):
PersistenceBroker broker = null;
try { broker=PersistenceBrokerFactory.defaultPersistenceBroker( );
// Just a sanity check. // I've never reached here inside // a existing transaction!!! if( !broker.isInTransaction( ) ) { broker.beginTransaction( ); }
broker.delete( o ); broker.commitTransaction( ); } catch( PersistenceBrokerException e ) { try { broker.abortTransaction( ); } catch( Exception e1 ) {} throw e1; //just rethrow the exception forward } finally { try { // I don't wan't to catch this... // If something important happens, // it'll be in log... broker.close( ); } catch( Exception e2 ) {} }
This way worked for me in SapDB and MS SQL Server 2K...
Best regards,
Edson Richter
Em Ter, 2003-07-15 �s 12:58, Dave Hodson escreveu:
I'm using SQL Server 2k, with the MSFT drivers Can you post a few snippets of your code?
Thx
Dave
-----Original Message-----
From: Ryan Vanderwerf [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 15, 2003 8:32 AM
To: OJB Users List
Subject: RE: ConnectionManager is already in transaction
I've had the same problems with the PB api too. What DB
Are you using?
The best way for me to get around it was to make wrapper
methods that
get and close broker connections, and to check the
transaction state
before trying to begin, commit, and abort a transaction.
I'm using SQL
Server 2k and the Inet Opta driver.
-----Original Message-----
From: Dave Hodson [mailto:[EMAIL PROTECTED] Sent: Monday, July 14, 2003 7:47 PM
To: [EMAIL PROTECTED]
Subject: ConnectionManager is already in transaction
I'm using 1.0RC3 and running into the following error:
"ConnectionManager is already in transaction" when trying to commit a new transaction to the DB.
Any queries by criteria or identity work properly. The method is a member of a class that is extended by others -- items to
be written to the DB are passed as generic objects.
Suggestions? What am I doing incorrectly?
Dave
Code is as follows: --------------------- protected void Put (Object o, Class c) { Transaction tx = odmg.newTransaction(); tx.begin(); try { // lock the product for write access tx.lock(o, tx.WRITE); tx.commit(); } catch (Throwable t) { tx.abort(); log.error("Put failed for " + c.getName() + " : " + t); } }
Stack is as follows:
------------------------
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR:
PersistenceBrokerException during the execution of the insert:
ConnectionManager is already in transaction ConnectionManager is already
in transaction
org.apache.ojb.broker.TransactionInProgressException:
ConnectionManager is already in transaction at org.apache.ojb.broker.core.PersistenceBrokerImpl.beginTransact ion(Persis tenceBrokerImpl.java:361) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.beginTr ansaction( DelegatingPersistenceBroker.java:114) at org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl .getSequen ce(SequenceManagerHighLowImpl.java:260) at org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl .getUnique Long(SequenceManagerHighLowImpl.java:201) at org.apache.ojb.broker.util.sequence.AbstractSequenceManager.ge tUniqueId( AbstractSequenceManager.java:252) at org.apache.ojb.broker.util.sequence.AbstractSequenceManager.ge tUniqueVal ue(AbstractSequenceManager.java:167) at org.apache.ojb.broker.util.BrokerHelper.getAutoIncrementValue( BrokerHelp er.java:303) at org.apache.ojb.broker.util.BrokerHelper.getValuesForObject(Bro kerHelper. java:349) at org.apache.ojb.broker.util.BrokerHelper.getAllRwValues(BrokerH elper.java :380) at org.apache.ojb.broker.accesslayer.StatementManager.getAllValue s(Statemen tManager.java:725) at org.apache.ojb.broker.accesslayer.StatementManager.bindInsert( StatementM anager.java:487) at org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeInsert (JdbcAcces sImpl.java:198) at org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(Per sistenceBr okerImpl.java:1919) at org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Persist enceBroker Impl.java:1834) at org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Persist enceBroker Impl.java:1792) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(D elegatingP ersistenceBroker.java:161) at org.apache.ojb.odmg.states.StateNewDirty.commit(StateNewDirty. java:148) at org.apache.ojb.odmg.ObjectEnvelopeTable.commitAllEnvelopes(Obj ectEnvelop eTable.java:234) at org.apache.ojb.odmg.ObjectEnvelopeTable.commit(ObjectEnvelopeT able.java: 189) at org.apache.ojb.odmg.TransactionImpl.doCommitOnObjects(Transact ionImpl.ja va:342) at
org.apache.ojb.odmg.TransactionImpl.prepare(TransactionImpl.java:595)
at
org.apache.ojb.odmg.TransactionImpl.commit(TransactionImpl.java:545)
at net.messagecast.rec.RecOJBMgr.Put(RecOJBMgr.java:83)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
---------------------------------------------------------------------To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
