You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Emmanuel Dupont <em...@jwaretechnologies.com> on 2003/06/17 12:53:10 UTC
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 com.jware.persistence.ojb.JwtTransactionImpl@b4e29b, associated PB was
org.apache.ojb.broker.singlevm.PoolablePersistenceBroker@125844f
[org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] INFO: Rollback was
called, do rollback on current connection
net.sourceforge.jtds.jdbc.TdsConnection@18941f7
[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.commitTransaction(Persi
stenceBrokerImpl.java:390)
at
org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.commitTransaction
(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;
}
RE : Lock bug ??
Posted by Emmanuel Dupont <em...@jwaretechnologies.com>.
Hi Armin,
I oblige to have a broker instance because I use the
getObjectByQuery(query) treatment
broker.getObjectByQuery(query);
-----Message d'origine-----
De : Armin Waibel [mailto:armin@code-au-lait.de]
Envoyé : mardi 17 juin 2003 14:46
À : OJB Users List
Objet : Re: Lock bug ??
Hi Emmanuel,
did you have tried without
broker.begin...
broker.commit...
statements?
regards,
Armin
----- Original Message -----
From: "Emmanuel Dupont" <em...@jwaretechnologies.com>
To: "OJB Users List" <oj...@db.apache.org>
Sent: Tuesday, June 17, 2003 12:53 PM
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 com.jware.persistence.ojb.JwtTransactionImpl@b4e29b, associated PB
was
org.apache.ojb.broker.singlevm.PoolablePersistenceBroker@125844f
[org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] INFO: Rollback
was
called, do rollback on current connection
net.sourceforge.jtds.jdbc.TdsConnection@18941f7
[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.commitTransaction(P
ersi
stenceBrokerImpl.java:390)
at
org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.commitTransac
tion
(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: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Lock bug ??
Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi Emmanuel,
did you have tried without
broker.begin...
broker.commit...
statements?
regards,
Armin
----- Original Message -----
From: "Emmanuel Dupont" <em...@jwaretechnologies.com>
To: "OJB Users List" <oj...@db.apache.org>
Sent: Tuesday, June 17, 2003 12:53 PM
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 com.jware.persistence.ojb.JwtTransactionImpl@b4e29b, associated PB
was
org.apache.ojb.broker.singlevm.PoolablePersistenceBroker@125844f
[org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] INFO: Rollback
was
called, do rollback on current connection
net.sourceforge.jtds.jdbc.TdsConnection@18941f7
[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.commitTransaction(P
ersi
stenceBrokerImpl.java:390)
at
org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.commitTransac
tion
(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;
}