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.  [ 4 posts ] 
Author Message
 Post subject: sharing transaction between NH and ADO
PostPosted: Sun Jun 17, 2007 10:57 am 
Newbie

Joined: Thu May 31, 2007 4:31 am
Posts: 5
Hi,
I want use Nhibernate with old application. So I need attach transaction of session to curently opened transaction of ADO. My code need be like:

void MyFunction(IDbTransaction adoTransaction)
{
ISession session = factory.OpenSession(adoTransaction.Connection);

// ....... here some code that make any manipulation with nhibernate ex:
Order myOrder = session.Get<Order>(224254);
order.ShippedDate = DateTime.Now;

session.Flush();
}

Where opening/commiting transaction will be done by method that called to MyFunction.
My code is crashed inside "session.Get<Order>(224254)" method with exception:
-------
ExecuteReader requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized.
-------
How i can do it?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 17, 2007 11:58 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Use ISession.Transaction.Enlist(your command).


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 17, 2007 2:12 pm 
Newbie

Joined: Thu May 31, 2007 4:31 am
Posts: 5
I can not use ISession.Transaction.Enlist(your command) because existing code of my programm dont know about NHibernte and I can not change it.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 17, 2007 2:34 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Doing it the other way around, i.e. passing an existing transaction to NHibernate, is currently not supported, but will be in the future.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.