-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How to manage sub transactions
PostPosted: Tue Jul 20, 2010 4:43 am 
Newbie

Joined: Tue Jul 20, 2010 3:25 am
Posts: 1
want to have something like sub-transactions, in that you can mark a point where you would start the sub-transaction, then at the point of descision for that bit, you can either roll-back (abort the sub-bit) or carry on, effectively commiting, when the out transation commits. Of course, if you abort the outer transaction, the marked bit aborts too.

How can I do that with NHibernate.I have the following code but it seems that the Transaction is set to null after thye first commit and hence i`m having the error message that
Quote:
no open transaction to commit
.

My code is as follows:

Code:
API.Data.Session session = API.Data.SessionManager.GetSession();
        session.BeginTransaction();
         try
        {
            Project project = Project.Load(ID);
            ...........
            Save(project);
            .....................

           session.CommitTransaction();
        }
         catch
         {
             session.RollbackTransaction();
             throw;
         }

Code:
public void save(Project project)
    {
Data.SessionManager.GetSession().BeginTransaction();
                try
                {
                    Save();
                    LogIssueChange(test);
                    Data.SessionManager.GetSession().CommitTransaction();
                }
                catch
                {
                    Data.SessionManager.GetSession().RollbackTransaction();
                    throw;
                }
    }


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.