Hi, I disabled the service's transaction
use-transaction="false"
and handle it manually. It seems to be fine, now.
boolean transactionBegan = TransactionUtil.begin();
Debug.logVerbose("transactionBegan = "+transactionBegan,
MODULE);
delegator.removeByCondition("TableA", completeCondition);
TransactionUtil.commit(transactionBegan);
Debug.logVerbose("transactionBegan = "+transactionBegan,
MODULE);
Debug.logVerbose("Deleting from tableA", MODULE);
transactionBegan = TransactionUtil.begin();
delegator.removeByCondition("TableB", completeCondition);
TransactionUtil.commit(transactionBegan);
Debug.logVerbose("Deleting from tableB", MODULE);
My output is:
transactionBegan = true
transactionBegan = true
Deleting from tableA
Deleting from tableB
Do I have to close the transaction after a commit and what is the
correct way?
Call TransactionUtil.suspend() and
TransactionUtil.cleanSuspendedTransactions()?
Thank you very much! Kind regards Marc Am 15.07.2014 11:51, schrieb Nicolas Malin:
Hi, Le 15/07/2014 10:12, Marc von der Brüggen a écrit :I'm really surprising on that ! If you haven't transaction available, your service don't open a transaction or you have disable on the entity engine your transaction manager.Hello Nicolas, thank you very much for your help. I tried it:Debug.logVerbose("### Store List Prices ("+productPrices.size()+") ###", MODULE);Transaction transaction = null; transaction = TransactionUtil.suspend(); boolean transactionBegan = TransactionUtil.begin(); delegator.storeAll(productPrices); TransactionUtil.commit(transactionBegan); TransactionUtil.resume(transaction); TransactionUtil.commit();Debug.logVerbose("### List Prices Stored ("+productPrices.size()+") ###", MODULE);but the output is still the same:[java] 2014-07-15 09:58:54,831 (default-invoker-Thread-6) [ OfbizPriceImporter.java:688:DEBUG] ### Store List Prices (1234) ### [java] 2014-07-15 09:58:54,831 (default-invoker-Thread-6) [ TransactionUtil.java:348:WARN ] No transaction in place, so not suspending.In this case just : boolean transactionBegan = TransactionUtil.begin(); delegator.storeAll(productPrices); TransactionUtil.commit(); works.[java] 2014-07-15 09:58:55,990 (default-invoker-Thread-6) [ TransactionUtil.java:210:WARN ] [TransactionUtil.commit] Not committing transaction, status is No Transaction (6) [java] 2014-07-15 09:58:55,990 (default-invoker-Thread-6) [ OfbizPriceImporter.java:696:DEBUG] ### List Prices Stored (1234) ###Kind regards Marc Am 10.07.2014 15:12, schrieb Nicolas Malin:Ok I understand.If you run a commit in your code at the service end, the transaction has been already commitedSo, open a new transaction like this : Transaction transaction = null; try { transaction = TransactionUtil.suspend(); boolean transactionBegan = TransactionUtil.begin(); delegator.storeAll(listOfGenericValues); TransactionUtil.commit(transactionBegan ); TransactionUtil.resume(transaction); } catch (YourExceptionLevel e) { Debug.logError(e, module); TransactionUtil.rollback(); TransactionUtil.resume(transaction); } Le 10/07/2014 14:59, Marc von der Brüggen a écrit :Hi Nicolas,I didn't set use-transaction="false", so that the service can handle the transactions by itself.Before I tried delegator.storeAll(listOfGenericValues); TransactionUtil.commit(); it looked like this: boolean transactionBegan = TransactionUtil.begin(); delegator.storeAll(listOfGenericValues); TransactionUtil.commit(transactionBegan ); However, transactionBegan was always false. Kind regards Marc Am 10.07.2014 11:59, schrieb Nicolas Malin:Do you open a transaction before ? TransactionUtil.begin(); delegator.storeAll(listOfGenericValues); TransactionUtil.commit(); Nicolas Le 10/07/2014 11:18, Marc von der Brüggen a écrit :Hello,does delegator.storeAll(listOfGenericValues) always perform a commit?I want to make sure the data is committed, but if I do the following:delegator.storeAll(listOfGenericValues); TransactionUtil.commit(); I receive a warning:[java] 2014-07-10 10:20:55,841 (default-invoker-Thread-6) [ TransactionUtil.java:210:WARN ] [TransactionUtil.commit] Not committing transaction, status is No Transaction (6)Thank you very much! Kind regards Marc
-- Marc von der Brüggen Software-EntwicklerZYRES digital media systems GmbH
Stuttgarter Straße 25 60329 Frankfurt am Main Phone +49 (0)69 98 55 99 - 23 Fax +49 (0)69 98 55 99 - 11 Firmensitz: Stuttgarter Straße 25 60329 Frankfurt am Main Registergericht: Amtsgericht Frankfurt am Main, HRB 76374 Geschäftsführer: Sebastian Schirmer http://www.zyres.com/
smime.p7s
Description: S/MIME Cryptographic Signature
