-->
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: Relationship between Session and Transaction
PostPosted: Tue Nov 15, 2005 10:48 pm 
Regular
Regular

Joined: Sun Sep 25, 2005 11:35 pm
Posts: 57
I found that in one of my programs I had forgotten to call session.BeginTransaction() and tx.Commit(). Effectively the sequence of calls was as follows:

session = sessionFactory.OpenSession();
// Now do some saves and updates
session.Close();

In spite of not calling BeginTransaction() and Commit(), objects were being created and updated properly. Why is this happening? Does NHibernate implicitly create transactions for me?

P.S. I am using SQL Server 2000 as my database


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 15, 2005 11:10 pm 
Regular
Regular

Joined: Sun Sep 25, 2005 11:35 pm
Posts: 57
Sorry, it appears that only saves were working, not updates. But it is still surprising that saves were working.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 16, 2005 7:05 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
You were using an identity (or native) identifier generator, so NH had to save the object right away before commit, to give you back its identifier.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 16, 2005 8:57 am 
Regular
Regular

Joined: Sun Sep 25, 2005 11:35 pm
Posts: 57
Aha, so that explains it! Thx.


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.