This is a migrated thread and some comments may be shown as answers.

Nested Transactions exception

9 Answers 192 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
egoren
Top achievements
Rank 1
egoren asked on 13 Aug 2009, 09:22 PM
Hi,
According to the documentation http://www.telerik.com/help/openaccess-orm/telerik.openaccess-telerik.openaccess.itransaction-begin.html I should be able to start a second transaction within an existing one. However, when I try to do that, I am getting the following exception: 'Transaction already active'.
Is there a way to have nested transactions in OpenAccess (as the documentation suggest)?
What I am trying to achieve is a unit test were I first 'save' the data within the nested transaction, then commit it and then retrieve the data within the outer transaction. Then I rollback everything. This way I know the code that writes to the db and the query works (see pseudo code below).

Thank you in advance, Eyal.

scope.Transaction.Begin();  
scope.Transaction.Begin();  
StoreData();  
scope.Transaction.Commit();  
RetrieveData(); // if OK, then the test is passed!  
scope.Transaction.Rollback();  
 
 

9 Answers, 1 is accepted

Sort by
0
PetarP
Telerik team
answered on 14 Aug 2009, 08:08 AM
Hello Eyal Goren,

This is old information left from our java implementation of the old product. Telerik OpenAccess ORM does not support nested transactions and this document is outdated. Thank you for bringing this to our attention. Your Telerik points were updated.

Best wishes,
Petar
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
egoren
Top achievements
Rank 1
answered on 14 Aug 2009, 01:40 PM
Thank you for the quick response, Petar.
Can you suggest another way for achieving a unit test for my case.
One of the reasons we have chosen OpenAccess as our ORM tool is unit testing.
If there is no way to apply our unit tests with OA, we might have to consider another tool...
Eyal.
0
PetarP
Telerik team
answered on 18 Aug 2009, 11:11 AM
Hi Eyal Goren,

You can use IObjectScope.Transaction.Flush(). This will temporarily flush all data in the current transaction to the SQL server without committing it. So when you call IObjectScope.Transaction.Rollback() everything from the flush will be removed. I hope that this will help you solve your problem. Let me know if I can assist you further.

All the best,
Petar
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
egoren
Top achievements
Rank 1
answered on 18 Aug 2009, 01:41 PM
Petar,
Thank you for the response. IObjectScope.Transaction.Flush() does exactly what we were looking for.
As I've mentioned, this was a crucial element in out unit testing strategy, and this solution will allow us to move forward.

You might want to write a quick article on how to achieve unit testing using this mechanism so that others can do the same.
Thanks again, Eyal.
0
PetarP
Telerik team
answered on 19 Aug 2009, 03:25 PM
Hi Eyal Goren,

We are actively working on expanding our documentation(articles, blog posts, knowledge bases, code libraries)  and such suggestions are always welcomed. We will most certainly add this topic as we feel that you are right and such topic might be useful for other customers as well. Also if you feel that we are missing content in other areas please do not hesitate to point them to us and we will address them as soon as possible.

Kind regards,
Petar
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Dirk
Top achievements
Rank 1
answered on 15 Mar 2010, 09:30 PM
Hi Petar,

sorry, but 7 month after the problem in the documentation was posted and confirmed by you, the document for the Begin-Method is still saying:

"Begins the transaction. If the transaction is already active, a new nesting level ist started."

But instead i still receive an exception 'Transaction already active'
Nested transactions would be very useful!

Please explain the strategy for this topic!
Would you implement nested transactions?
Would you change the documentation?

Best regards
Dirk
0
PetarP
Telerik team
answered on 17 Mar 2010, 05:53 PM
Hi Dirk,

You are correct. The documentation was indeed not updated correctly. From now on the description will state the following:
Begins a new transaction. If there is another transaction already running an exception will be thrown. 
Currently we do not plan support for nested transactions.

Sincerely yours,
Petar
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
JoeB
Top achievements
Rank 1
answered on 15 Jun 2010, 09:08 PM
Your documentation is still out of date.  I've spent several hours today trying to troubleshoot this before I found your article.  Even better, why not consider supporting nested transactions since they were apparantly supported at one time.  It would be very handy, as I can't guarantee what code is firing before or after my method and would hate to commit data someone else didn't intend to commit.
0
Pencho
Telerik team
answered on 17 Jun 2010, 06:35 PM
Hi JoeB,

Unfortunately our online help is out of date. We will do our best to update it as soon as possible. For now you should use the installed help in .chm format, part of the latest internal build of the product released on the 10th of June(version 2010.610.1).
If you need more information regarding transactions please refer to the following topics:
-Programmers Guide/OpenAccess ORM Visual Designer/Programming Guide/OpenAccess Tasks/Defining a Domain Model/How to: Work with Transactions - This topic will show you how to perform transactions by using the OpenAccessContext. Please consider that this part of the help is still under development and will be ready for our next major release. We are planning to extend especially this topic.
-Programmers Guide/OpenAccess ORM Classic/Programming with OpenAccess/Transactions - note that the information in this section regards the classic version of Telerik OpenAccess ORM (Reverse Mapping/Forward Mapping Wizards/IObjectScope).
If you feel there is a missing content in the current version of the help, do not hesitate to share with us and we will address it.

Regards,

Pencho
the Telerik team

 

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Development (API, general questions)
Asked by
egoren
Top achievements
Rank 1
Answers by
PetarP
Telerik team
egoren
Top achievements
Rank 1
Dirk
Top achievements
Rank 1
JoeB
Top achievements
Rank 1
Pencho
Telerik team
Share this question
or