Ok, I just experienced this:
ISession session = s.CreateSession();
User user = new User();
user.Number = 122;
user.UserName = "u";
user.Id = 1;
session.Save(user);
User user1 = session.CreateCriteria<User>().Add(Restrictions.Eq("UserName", "u")).UniqueResult<User>();
session.Flush();
First you select from CreateCriteria, and then to reset the insert. Therefore, so that he does not find anything.
I also tested with Get<User>(1)and returns the object passed to the Save method - the request is not executed.
However - why query the database since you have an entity?
In addition, you say that you use Get, and then say that you want to load UserName - is UserName the main key? Try loading the primary key.
source
share