I would like to have an opinion on a behavior that I found when I use INSERT command with stateless session on NHibernate (NB. I use NHibernate 2.1.2)
The case is this
//STATEFULL SESSION
var session = sessionFactory.OpenSession()
using(var transaction = session.BeginTransaction()){
var entity = new MyEntityType();
entity.Id = 1;
session.Save(entity);
var entity2 = session.Get<MyEntityType>(1);
//OK! It returns saved entity...as I expect
transaction.Commit();
}
but...on stateless session, the behavior changes...
//STATELESS SESSION
var session = sessionFactory.OpenStatelessSession()
using(var transaction = session.BeginTransaction()){
var entity = new MyEntityType();
entity.Id = 1;
session.Insert(entity);
var entity2 = session.Get<MyEntityType>(1);
//entity2 IS NULL!!! Why?
transaction.Commit();
}
My question is...how can I check if I already inserted an item on transaction scope of stateless session?