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 Ju...@Bertelsmann.de on 2003/07/09 15:25:35 UTC
transaction in JBoss with MySQL Datasource
Hello!
I' using JBoss 3.0.6, OJB rc3 and a MySQL Database, which is configured as a
Datasource for Local Transaction.
I'm trying to delete an object but I'm having some problems with the
transaction. I have tried several things with the following results:
---------------------
1. Use only of org.odmg.Transaction:
Transaction tx = odmg.currentTransaction();
if ( !tx.isOpen())
tx.begin();
db.deletePersistent(toBeDeleted); /* here it crashes */
tx.commit();
Result:
org.odmg.TransactionNotInProgressException: No external transaction found
at org.apache.ojb.odmg.JTATxManager.registerTx(Unknown Source)
at org.apache.ojb.odmg.TransactionImpl.begin(Unknown Source)
at org.apache.ojb.odmg.OJBJ2EE_2.beginInternTransaction(Unknown
Source)
at org.apache.ojb.odmg.OJBJ2EE_2.currentTransaction(Unknown Source)
at
de.arvatosystems.monitoring.integration.dao.server.ServerOjbDAO.delete(Serve
rOjbDAO.java:227)
-------------------
2. Use only of UserTranscation:
UserTransaction userTx = (UserTransaction)
context.lookup("java:/comp/UserTransaction");
userTx.begin();
db.deletePersistent(toBeDeleted); /* here it crashes */
userTx.commit();
Result:
org.odmg.TransactionNotInProgressException: No transaction in progress,
cannot delete persistent
at org.apache.ojb.odmg.DatabaseImpl.deletePersistent(Unknown Source)
at
de.arvatosystems.monitoring.integration.dao.server.ServerOjbDAO.delete
(ServerOjbDAO.java:230)
---------------------
3. Use of both (Transaction and UserTransaction combined):
UserTransaction userTx = (UserTransaction)
context.lookup("java:/comp/UserTransaction");
userTx.begin();
Transaction tx = odmg.currentTransaction();
if ( !tx.isOpen())
tx.begin();
db.deletePersistent(toBeDeleted);
tx.commit(); /* here it crashes */
userTx.commit();
Result:
java.lang.UnsupportedOperationException: Not supported operation
at org.apache.ojb.odmg.NarrowTransaction.commit(Unknown Source)
at
de.arvatosystems.monitoring.integration.dao.server.ServerOjbDAO.delete(Serve
rOjbDAO.java:232)
---------------------
4. like 3 but I uncomment tx.commit(). No exceptions but the object is not
deleted. No SQL statement is generated by OJB.
I know it is a lot to read but maybe somebody can take some time to read my
code.
Where is my problem and which transactions should I use? Or is the
configuration of my Datasource wrong?
Thanks, Julia.
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: transaction in JBoss with MySQL Datasource
Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi,
try to use JTA UserTransaction or container-managed tx
and do not use ODMG tx-declaration.
UserTransaction utx = ...
utx.begin()
> db.deletePersistent(toBeDeleted); /* here it crashes */
utx.commit()
HTH
regards,
Armin
----- Original Message -----
From: <Ju...@Bertelsmann.de>
To: <oj...@db.apache.org>
Sent: Wednesday, July 09, 2003 3:25 PM
Subject: transaction in JBoss with MySQL Datasource
> Hello!
>
> I' using JBoss 3.0.6, OJB rc3 and a MySQL Database, which is
configured as a
> Datasource for Local Transaction.
>
> I'm trying to delete an object but I'm having some problems with the
> transaction. I have tried several things with the following results:
>
> ---------------------
> 1. Use only of org.odmg.Transaction:
>
> Transaction tx = odmg.currentTransaction();
> if ( !tx.isOpen())
> tx.begin();
> db.deletePersistent(toBeDeleted); /* here it crashes */
> tx.commit();
>
> Result:
> org.odmg.TransactionNotInProgressException: No external transaction
found
> at org.apache.ojb.odmg.JTATxManager.registerTx(Unknown Source)
> at org.apache.ojb.odmg.TransactionImpl.begin(Unknown Source)
> at
org.apache.ojb.odmg.OJBJ2EE_2.beginInternTransaction(Unknown
> Source)
> at org.apache.ojb.odmg.OJBJ2EE_2.currentTransaction(Unknown
Source)
> at
>
de.arvatosystems.monitoring.integration.dao.server.ServerOjbDAO.delete(S
erve
> rOjbDAO.java:227)
>
> -------------------
> 2. Use only of UserTranscation:
> UserTransaction userTx = (UserTransaction)
> context.lookup("java:/comp/UserTransaction");
> userTx.begin();
> db.deletePersistent(toBeDeleted); /* here it crashes */
> userTx.commit();
>
> Result:
> org.odmg.TransactionNotInProgressException: No transaction in
progress,
> cannot delete persistent
> at org.apache.ojb.odmg.DatabaseImpl.deletePersistent(Unknown
Source)
> at
> de.arvatosystems.monitoring.integration.dao.server.ServerOjbDAO.delete
> (ServerOjbDAO.java:230)
>
> ---------------------
> 3. Use of both (Transaction and UserTransaction combined):
>
> UserTransaction userTx = (UserTransaction)
> context.lookup("java:/comp/UserTransaction");
> userTx.begin();
> Transaction tx = odmg.currentTransaction();
> if ( !tx.isOpen())
> tx.begin();
> db.deletePersistent(toBeDeleted);
> tx.commit(); /* here it crashes */
> userTx.commit();
>
> Result:
> java.lang.UnsupportedOperationException: Not supported operation
> at org.apache.ojb.odmg.NarrowTransaction.commit(Unknown
Source)
> at
>
de.arvatosystems.monitoring.integration.dao.server.ServerOjbDAO.delete(S
erve
> rOjbDAO.java:232)
>
> ---------------------
> 4. like 3 but I uncomment tx.commit(). No exceptions but the object is
not
> deleted. No SQL statement is generated by OJB.
>
>
> I know it is a lot to read but maybe somebody can take some time to
read my
> code.
> Where is my problem and which transactions should I use? Or is the
> configuration of my Datasource wrong?
>
> Thanks, Julia.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org