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.  [ 2 posts ] 
Author Message
 Post subject: transaction does not rollback
PostPosted: Sun Aug 13, 2006 10:11 am 
Newbie

Joined: Sun Dec 21, 2003 1:59 pm
Posts: 5
Hi community,

I use NHibernate 1.0.2 with the mysql server. In my program I created some objects that are controlled by NHibernate. In a special point in my program I had found out that something is wrong and I tried to rollback all the changes (NHibernate.Transaction.AdoTransaction.Rollback()). At this point I get a System.InvalidOperationException with the message "The SqlCommand is currently busy Open, Fetching.".

If I use mysql I get a MySql.Data.MySqlClient.MySqlException with the message "There is already an open DataReader associated with this Connection which must be closed first."

Any idea what I do wrong?

Regards Philipp


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 14, 2006 3:05 pm 
Newbie

Joined: Sun Dec 21, 2003 1:59 pm
Posts: 5
Hi,

I found the problem :-).
I used an iterator like:
Code:
      private const String queryFindVersionNumbers = "select max( pd.Version ) " +
         "from pd in class NetBpm.Workflow.Definition.Impl.ProcessDefinitionImpl " +
         "where pd.Name = ? ";

   private Int32 GetVersionNr(CreationContext creationContext)
      {
         int newVersion = 1;
         IEnumerator iter = creationContext.DbSession.Iterate(queryFindVersionNumbers, _name, DbType.STRING).GetEnumerator();
         if(iter.MoveNext())
         {
            Int32 highestVersionNumber = (Int32) iter.Current;
            if ((Object) highestVersionNumber != null)
            {
               newVersion = highestVersionNumber + 1;
            }
         }
         return newVersion;
      }

The problem is that the iterator is not closed and it is blocking the rollback. I changed the source to:
Code:
      private const String queryFindVersionNumbers = "select max( pd.Version ) " +
         "from pd in class NetBpm.Workflow.Definition.Impl.ProcessDefinitionImpl " +
         "where pd.Name = ? ";
      private Int32 GetVersionNr(CreationContext creationContext)
      {
         int newVersion = 1;
         IEnumerator iter = creationContext.DbSession.Iterate(queryFindVersionNumbers, _name, DbType.STRING).GetEnumerator();
         while (iter.MoveNext())
         {
            Int32 highestVersionNumber = (Int32) iter.Current;
            if ((Object) highestVersionNumber != null)
            {
               newVersion = highestVersionNumber + 1;
            }
         }
         return newVersion;
      }

Now it works fine.

Regards Philipp


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

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.