Nested Transactions exception

10 posts, 0 answers
  1. egoren
    egoren avatar
    11 posts
    Member since:
    Apr 2009

    Posted 13 Aug 2009 Link to this post

    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();  
     
     
  2. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 14 Aug 2009 Link to this post

    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.
  3. DevCraft banner
  4. egoren
    egoren avatar
    11 posts
    Member since:
    Apr 2009

    Posted 14 Aug 2009 Link to this post

    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.
  5. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 18 Aug 2009 Link to this post

    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.
  6. egoren
    egoren avatar
    11 posts
    Member since:
    Apr 2009

    Posted 18 Aug 2009 Link to this post

    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.
  7. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 19 Aug 2009 Link to this post

    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.
  8. Dirk
    Dirk avatar
    1 posts
    Member since:
    Sep 2008

    Posted 15 Mar 2010 Link to this post

    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
  9. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 17 Mar 2010 Link to this post

    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.
  10. JoeB
    JoeB avatar
    1 posts
    Member since:
    May 2006

    Posted 15 Jun 2010 Link to this post

    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.
  11. Pencho
    Admin
    Pencho avatar
    22 posts

    Posted 17 Jun 2010 Link to this post

    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
Back to Top
DevCraft banner