Hi, > What is it wrong in this ?? TransactionImpl does internally use the PB instance you call with PersistenceBroker broker = ((HasBroker) tx).getBroker()
on tx.commit() TransactionImpl lookup the PB instance (broker) and start a PB-tx, does all work and commit the PB-tx. ODMG-api internally does all PB-tx demarcation. Thus don't do PB-tx demarcation when using the internal PB-instance of odmg Transaction implementation. This should work without problems: // Create a new ODMG Tx tx = odmg.newTransaction(); // Start it tx.begin(); // Catch a broker on it PersistenceBroker broker = ((HasBroker) tx).getBroker(); // Use the broker for using the PB API broker.getObjectByQuery(query) // Stop the ODMG Tx tx.commit(); regards, Armin ----- Original Message ----- From: "Emmanuel Dupont" <[EMAIL PROTECTED]> To: "'OJB Users List'" <[EMAIL PROTECTED]>; "'Armin Waibel'" <[EMAIL PROTECTED]>; "'Mahler Thomas'" <[EMAIL PROTECTED]> Sent: Tuesday, June 17, 2003 3:37 PM Subject: RE : Lock bug ?? Hi Thomas, Armin In fact the " jwtImpl.newJwtTransaction();" Do : TransactionImpl tx = new TransactionImpl (getCurrentDatabase()); It instantiate a new transaction Maybe I'm wrong, but I thought that I was obliged to use the Broker like that in with theODMG/PB API both used. // Create a new ODMG Tx Tx = newTransaction(); // Start it Tx.begin(); // Catch a broker on it PersistenceBroker broker = ((HasBroker) tx).getBroker(); // Start the broker transaction broker.beginTransaction(); // Use the broker for using the PB API broker.getObjectByQuery(query) // Stop the broker tx broker.commitTransaction(); // Stop the ODMG Tx tx.commit(); What is it wrong in this ?? Each time I call this method a new Tx is create, so why failed the lock ? Armin, I tried to put off the broker.beginTransaction() and broker.commit() But I have now this error on the second in the lock line....very weird ??? It is not the same transaction !! : org.apache.ojb.odmg.TransactionImpl] INFO: Abort transaction was called on tx [EMAIL PROTECTED], associated PB was [EMAIL PROTECTED] [JwtBOjects] null org.odmg.TransactionNotInProgressException: Transaction was not open, call tx.begin() before perform action, current status is: STATUS_ROLLEDBACK at org.apache.ojb.odmg.TransactionImpl.checkOpen(TransactionImpl.java:210) at org.apache.ojb.odmg.TransactionImpl.commit(TransactionImpl.java:522) at com.jware.persistence.ojb.JwtTransactionImpl.commit(JwtTransactionImpl.j ava: 127) at com.jware.businessobjects.JwtBOjects.getNextOId(JwtBOjects.java:131) at com.jware.test.businessobjects.ApplicationACL.run(ApplicationACL.java:52 ) at com.jware.test.businessobjects.ApplicationACL.main(ApplicationACL.java:3 8) Exception in thread "main" -----Message d'origine----- De : Mahler Thomas [mailto:[EMAIL PROTECTED] Envoyé : mardi 17 juin 2003 14:57 À : 'OJB Users List' Objet : RE: Lock bug ?? Hi Emmanuel, don't call broker.commitTransaction(); what does jwtImpl.newJwtTransaction(); do? does it really instantiate a *new* transaction? I have the impression that you work on the same transaction instance and try to re-use the already closed broker transaction... cheers, thomas > -----Original Message----- > From: Emmanuel Dupont [mailto:[EMAIL PROTECTED] > Sent: Tuesday, June 17, 2003 12:53 PM > To: OJB Users List > Subject: Lock bug ?? > > > Hi all, > > > > Can someone tell me what is wrong with this piece of code ?? > I'm using OJB, > rc1. > > > > > > When I call this method twice it failed on the second call on > the lock line. > I have only one column in my table. IT is an OID table generator. > > Whith : > > > > [org.apache.ojb.odmg.TransactionImpl] INFO: Abort transaction > was called on > tx [EMAIL PROTECTED], > associated PB was > [EMAIL PROTECTED] > > [org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] > INFO: Rollback was > called, do rollback on current connection > [EMAIL PROTECTED] > > [BOjects] null > > java.lang.ClassCastException > > TransactionImpl.lock(JwtTransactionImpl.java:86) > > BOjects.getNextOId(BOjects.java:112) > > org.apache.ojb.broker.TransactionNotInProgressException: > ConnectionManager > is NOT in transaction > > at > org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.commitTra > nsaction(Persi > stenceBrokerImpl.java:390) > > at > org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.com > mitTransaction > (DelegatingPersistenceBroker.java:117) > > at BOjects.getNextOId(JwtBOjects.java:124) > > Exception in thread "main" > > > > > > When I try to parse the code in the debugger, I doesn't > failed ..??? Does > that means there is some synchronization problems ? > > > > Tx, a lot, any help would be appreciated.. > > > > -------------------------------------------- > > public long getNextOId(Class oidObjectClass) { > > JwtTransaction tx = jwtImpl.newJwtTransaction(); > > tx.begin(); > > JwtDatabase db = jwtImpl.getJwtDatabase(null); > > > > PersistenceBroker broker = ((HasBroker) tx).getBroker(); > > broker.beginTransaction(); > > > > long result = -1; > > > > try { > > Query query = new QueryByCriteria(oidObjectClass, null); > > > > IObject oidObject = (IObject) broker.getObjectByQuery(query); > > > > // Check and increment the Oid ID > > result = oidObject.getId(); > > > > // Delete the old oidObject > > db.deletePersistent(oidObject); > > > > // Create a new OidObject > > oidObject newOidObject = new oidObject (); > > > > // Lock the nextObject for write access > > tx.lock(newOidObject, WRITE); ///FAILED ON THE SECOND CALL > > > > // Set the modification > > oidObject.setId(result+1); > > > > } catch (Exception e) { > > // rollback in case of errors > > tx.abort(); > > System.err.println("[BOjects] " + e.getMessage()); > > e.printStackTrace(); > > } > > > > broker.commitTransaction(); > > tx.commit(); > > > > return result; > > } > > --------------------------------------------------------------------- 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]