-->
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: IDbCommand Transaction and Session Transaction
PostPosted: Fri Oct 12, 2007 11:33 pm 
Newbie

Joined: Sat Jun 09, 2007 9:40 am
Posts: 11
I'm doing mostly non persisted Transformers.AliasToBean type IQuery queries with NH. I get an IDbConnection from factory.session and then do plain ado using IDbCommand for stored procedures, etc.

I have sarted a transaction with the IDbCommand. After that when I try to do an IQuery it says that the session transaction is not set.

Is there a way to pass the IDbCommand transaction back to the session transaction?

Can I start a session transaction and pass the transaction to the IDbCommand. Would these transaction be synchronized in the same unit of work?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 13, 2007 6:26 am 
Expert
Expert

Joined: Tue Aug 23, 2005 5:52 am
Posts: 335
Richard12345,

1. Obtain begin your transaction in NHibernate - you'll get an ITransaction.
2. Get your IDbConnection from the session.
3. Create your IDbCommand and assign it to use the IDbConnection.
4. Call the Enlist method on the ITransaction and pass it the IDbCommand.

You're already doing steps 2 and 3 - you just need to get steps 1 and 4 into the mix. That'll do what you're after I think.

Cheers,

Symon.


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.