-->
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.  [ 3 posts ] 
Author Message
 Post subject: ISession and ITransaction
PostPosted: Thu Sep 01, 2005 3:08 pm 
Regular
Regular

Joined: Mon Aug 29, 2005 3:07 pm
Posts: 77
Hi,

I'm studying NHibernate a bit, and I wonder why ISession and ITransaction are separated.
I see that the Session has a reference to the transaction (if any) that has been started on this session, but I wonder what the added value is of separating those two.
Why did the NHibernate designers/devvers opt for this, and why didn't they choose for 'combining' these 2 classes into one ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 02, 2005 5:55 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
NHibernate is a port of Hibernate (so they have the same design).

AFAIK, Sessions and Transactions are not coupled together because you can use a session without creating a transaction and you can create many transactions (one at a time) through the life of a session...
And they have differents functionnalities so it is probably a good design to keep them separated.

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 02, 2005 9:30 am 
Regular
Regular

Joined: Mon Aug 29, 2005 3:07 pm
Posts: 77
Indeed, they have different responsabilities.

However, if a transaction object would not be visible outside a session that would not be problematic.
As far as I know, you cannot have multiple transactions that are 'alive' at the same time, if the share the same connection.
If you use a session, without using a transaction, it would also not be a problem: the transaction object is just encapsulated into the session object.

I think, it will keep the api simpler if these 2 objects 'were put in one class'.

The Session object would then have a StartTransaction method (like it has now), but it would also have a commit and rollback transaction.
This would not be a problem if 'paralel transactions' are not supported. However, if you have a database, which allows nested transactions, it can be a problem.
(AFAIK, the SqlClient and OleDb providers do not allow you to start a transaction on a connection, if another transaction was already started on that connection).


note: I'm not critizizing the design of hibernate; I'm just thinking and wondering.


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