|
From: Ricardo P. (JIRA) <nh...@gm...> - 2011-05-24 09:23:52
|
[ http://216.121.112.228/browse/NH-2727?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21169#action_21169 ]
Ricardo Peres commented on NH-2727:
-----------------------------------
The scenario is this:
#1: OK
using (ISession session = sessionFactory.OpenSession())
{
UserGroup ug = session.Query<UserGroup>().FirstOrDefault();
User u = ug.User;
Debug.Assert(session.IsChanged(ug) == false);
Debug.Assert(session.IsChanged(u) == false);
Debug.Assert(ug.User == u);
Debug.Assert(session.IsDirty() == false);
}
#2: Problem
using (ISession session = sessionFactory.OpenSession())
{
User u = session.Query<User>().FirstOrDefault();
UserGroup ug = u.UserGroup.First();
Debug.Assert(session.IsChanged(ug) == false);
Debug.Assert(session.IsChanged(u) == false);
Debug.Assert(ug.User == u);
Debug.Assert(session.IsDirty() == false); //SaveOrUpdate event is raised, which, in my case, triggers a change in an entity, causing the session to be dirty
}
#3: Problem
using (ISession session = sessionFactory.OpenSession())
{
session.Query<UserGroup>().ToList(); //even if I preload all UserGroups, the event is still raised
User u = session.Query<User>().FirstOrDefault();
UserGroup ug = u.UserGroup.First();
Debug.Assert(session.IsChanged(ug) == false);
Debug.Assert(session.IsChanged(u) == false);
Debug.Assert(ug.User == u);
Debug.Assert(session.IsDirty() == false); //SaveOrUpdate event is raised, which, in my case, triggers a change in an entity, causing the session to be dirty
}
> Calling ISession.IsDirty Raises SaveOrUpdate Event
> --------------------------------------------------
>
> Key: NH-2727
> URL: http://216.121.112.228/browse/NH-2727
> Project: NHibernate
> Issue Type: Bug
> Components: Core
> Affects Versions: 3.1.0, 3.2.0Beta1
> Reporter: Ricardo Peres
> Attachments: FlushTest.zip
>
>
> When calling ISession.IsDirty() after loading an entity which lazy loads another one and doing nothing to them, the SaveOrUpdate event is raised on the lazy loaded entity.
> This doesn't happen all the time, only if the lazy loaded entity is not specifically loaded beforehand.
> The included test creates the DB and populates it with test records. The HIBERNATE_UNIQUE_KEY table must be created first, since SchemaUpdate does not create it.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|