NHibernate - Is ITransaction.Commit really necessary?
Posted
by user365383
on Stack Overflow
See other posts from Stack Overflow
or by user365383
Published on 2010-06-12T20:30:36Z
Indexed on
2010/06/12
20:32 UTC
Read the original article
Hit count: 162
nhibernate
Hi
I've just start studying NHibernate 2 days ago, and i'm looking for a CRUD method that i've writed based on an tutorial. My insert method is:
using (ISession session = Contexto.OpenSession())
using (ITransaction transaction = session.BeginTransaction())
{
session.Save(noticia);
transaction.Commit();
session.Close();
}
The complete code of "Contexto" is here: http://codepaste.net/mrnoo5
My question is: Do i really need to use ITransaction transaction = session.BeginTransaction() and transaction.Commit();?
I'm asking this because i've tested run the web app without those two lines, and i've sucefully inserted new records.
If possible, can someone explain me too the porpuse of Itransaction and the method Commit?
Thanks
© Stack Overflow or respective owner