[ http://216.121.112.228/browse/NH-1965?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Fabio Maulo closed NH-1965.
---------------------------
Resolution: Obsolete
The test is available in our sources; it does not fail in NH3.2
> CLONE -Lock(obj, LockMode.None) not working when there is collection
> --------------------------------------------------------------------
>
> Key: NH-1965
> URL: http://216.121.112.228/browse/NH-1965
> Project: NHibernate
> Issue Type: Improvement
> Components: Core
> Affects Versions: 2.1.0.GA
> Reporter: Offir
> Priority: Major
>
> As we all know, there are two means of re-attach a detached object: 1) sess.Update(obj) and 2) sess.Lock(c, LockMode.None);
> In 1.2.0 Alpha1, the second meanning does not work. If there is a collection in the entity, Lock() will throw an exception (but now error was found in the log file).
> Here are the code and the mapping file, which can also be found in the attachment.
> ////////ReAttachTest.cs////////////
> [TestFixture]
> public class ReAttachTest {
> [Test]
> public void ReAttachCatTest() {
> Configuration cfg = new Configuration();
> cfg.AddAssembly("NHSessTest");
> ISessionFactory fct = cfg.BuildSessionFactory();
> ISession sess = fct.OpenSession();
> Cat c = new Cat();
> sess.Save(c);
> sess.Clear();
>
> sess.Update(c); //Update() works fine
>
> sess.Clear();
>
> sess.Lock(c, LockMode.None); //Exception throw here
>
> sess.Close();
> }
> }
> /////Exception info/////////////////////
> NHibernate.HibernateException: reassociated object has dirty collection reference
> at NHibernate.Impl.OnLockVisitor.ProcessCollection(Object collection, CollectionType type) in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\OnLockVisitor.cs:line 58
> at NHibernate.Impl.AbstractVisitor.ProcessValue(Object value, IType type) in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\AbstractVisitor.cs:line 57
> at NHibernate.Impl.AbstractVisitor.ProcessValues(Object[] values, IType[] types) in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\AbstractVisitor.cs:line 30
> at NHibernate.Impl.AbstractVisitor.Process(Object obj, IEntityPersister persister) in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\AbstractVisitor.cs:line 82
> at NHibernate.Impl.SessionImpl.Reassociate(Object obj, Object id, IEntityPersister persister) in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs:line 1983
> at NHibernate.Impl.SessionImpl.Lock(Object obj, LockMode lockMode) in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs:line 2025
> at NHSessTest.Tests.Work.ReAttachTest.ReAttachCatTest() in ReAttachTest.cs:line 23
> ///////////Cat.cs///////////
> using System;
> using System.Collections;
> using System.Text;
> namespace NHSessTest{
> public class Cat{
> private int id;
> private IList children = new ArrayList();
> //Note: I initialized the collection here, if removed, Lock will work.
> public int Id{
> get { return id; }
> set { id = value; }
> }
> public IList Children {
> get { return children; }
> set { children = value; }
> }
> }
> }
> ///////////Cat.hbm.xml/////////
> <?xml version="1.0" encoding="utf-8" ?>
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" schema="dbo" assembly="NHSessTest" default-lazy="false">
> <class name="NHSessTest.Cat" >
> <id name="Id" type="Int32" unsaved-value="0" >
> <generator class="identity" />
> </id>
>
> <bag name="Children" cascade="all-delete-orphan" lazy="true">
> <key column="parentId" />
> <one-to-many class="NHSessTest.Cat" />
> </bag>
> </class>
> </hibernate-mapping>
--
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
|