|
From: Ricardo P. (JIRA) <nh...@gm...> - 2011-05-23 15:01:41
|
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.2.0Beta1, 3.1.0
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
|
|
[nhibernate-issues] [NHJIRA] Commented: (NH-2727) Calling
ISession.IsDirty Raises SaveOrUpdate Event
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
|
|
From: Fabio M. (JIRA) <nh...@gm...> - 2011-05-24 12:36:45
|
[ http://216.121.112.228/browse/NH-2727?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Fabio Maulo closed NH-2727.
---------------------------
Resolution: Not an Issue
In the title you are describing the default behavior of DefaultDirtyCheckEventListener.
> 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
|
|
[nhibernate-issues] [NHJIRA] Commented: (NH-2727) Calling
ISession.IsDirty Raises SaveOrUpdate Event
From: Ricardo P. (JIRA) <nh...@gm...> - 2011-05-25 20:21:54
|
[ http://216.121.112.228/browse/NH-2727?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21197#action_21197 ]
Ricardo Peres commented on NH-2727:
-----------------------------------
For the record, here is what happens: when an entity is lazily loaded from a one-to-many association, its lock mode is set to
Read, not None (in memory, at least).
If lazy loading is disabled, its lock mode is None, and it no longer fires the event, which, I suppose, is the expected behavior.
> 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
|