Armin,

Here my code modified as you told me.


I have exactly the same error :

[org.apache.ojb.odmg.TransactionImpl] INFO: Abort transaction was called on
tx [EMAIL PROTECTED], associated PB was
[EMAIL PROTECTED]
[JwtBOjects] Can not lock oid : 0
 for WRITE
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.businessobjects.JwtBOjects.getNextOId(JwtBOjects.java:158)
        at
com.jware.test.businessobjects.ApplicationACL.run(ApplicationACL.java:54)
        at
com.jware.test.businessobjects.ApplicationACL.main(ApplicationACL.java:38)
Exception in thread "main"


I'm under WSAD5, Ojb RC1, MSSQLServer. My table has only one column with is
the Primary Key. 

If I put the :"tx.lock(newOidObject, JwtTransaction.WRITE);"
After the : "((JwtOIDobject)newOidObject).setUniqueOID(result + 1);"

It is oK. Is there something relies on the fact that my column is alone and
is a PK ?

Anyway, if I let the lock before the set, what is really very weird is that,
when I parse the code with the debudder, 10 calls to this methods are oK but
when I launch it without the debugger it failed on the second calls.

It seems that there are some synchronization problem. I

Is there any chance to me If I try to install the Rc3 ?


--------------------------------------------------
public long getNextOId(Class oidObjectClass) {

Implementation impl = null; 
Transaction tx = null;
long result = -1;
try {
        impl = OJB.getInstance();
        Database db = impl.newDatabase();

        // Open database
        db.open("ACL", Database.OPEN_READ_WRITE);

        tx = impl.newTransaction();
        tx.begin();

        PersistenceBroker broker = ((HasBroker) tx).getBroker();

        Query query = new QueryByCriteria(Acl_oid_object_id.class, null);
        IAcl_oid_object_id oidObject = (IAcl_oid_object_id)     

        broker.getObjectByQuery(query);

        // Check and increment the Oid ID
        result = ((JwtOIDobject) oidObject).getUniqueOID();

        // Delete the old oidObject             
        db.deletePersistent(oidObject);

        // Create a new OidObject
        Acl_oid_object_id newOidObject = new Acl_oid_object_id();
                        
        // Lock the nextObject for write access 
        tx.lock(newOidObject, JwtTransaction.WRITE);

        // Set the modification
        ((JwtOIDobject)newOidObject).setUniqueOID(result + 1);

} catch (DatabaseOpenException jwte) {
        jwte.printStackTrace();
} catch (DatabaseNotFoundException jwte) {
        jwte.printStackTrace();
} catch (Exception e) {
        // rollback in case of errors
        tx.abort();
        System.err.println("[JwtBOjects] " + e.getMessage());
} catch (Throwable t) {
        t.printStackTrace();
}
tx.commit();

return result;
}


[Snip]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to