Hello everyone,
Is the following expectation valid? (it fails for me because the
second ITransaction causes c1's EntityVersion to increase by 1, even
though in my example )
Class1 c1;
Class2 c2;
Class1DTO dto;
using (ISession s = _sessions.OpenSession())
{
using (ITransaction tx = s.BeginTransaction())
{
c1 = new Class1();
c2 = new Class2();
c1.AddClass2(c2);
s.Save(c2);
s.Save(c1);
tx.Commit();
}
using (ITransaction tx = s.BeginTransaction())
{
dto = new Class1DTO { ID = c1.ID, EntityVersion = c1.EntityVersion };
tx.Commit();
}
Assert.AreEqual(1, c1.EntityVersion);
Assert.AreEqual(1, c2.EntityVersion);
Assert.AreEqual(1, dto.EntityVersion);
}
Assert.AreEqual(1, c1.EntityVersion);
Assert.AreEqual(1, c2.EntityVersion);
Assert.AreEqual(1, dto.EntityVersion);
Class1 and Class2 are mapped many-to-many. Mappings are attached. I
have opened a JIRA (http://nhjira.koah.net/browse/NH-2100) however I
suspect in hindsight my expectations of how ISession and ITransaction
interoperate is incorrect.
Thanks,
Luke
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.
<?xml version="1.0" encoding="utf-8" ?>
<!--
vim:sw=2:ts=2:expandtab:fo=tcqro:ai:encoding=utf-8
-->
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="TestNHibernate.Domain"
namespace="TestNHibernate.Domain"
default-lazy="true"
default-cascade="none"
schema="dbo">
<class name="Class1">
<id name="ID">
<generator class="increment"/>
</id>
<version name="EntityVersion"/>
<idbag name="Class2List" table="Class1_Class2" cascade="none" lazy="true"
inverse="true" access="field.camelcase-underscore">
<collection-id column="ID" type="Guid">
<generator class="guid.comb" />
</collection-id>
<key column="Class1ID" foreign-key="FK_Class2_Class1" />
<many-to-many class="Class2" column="Class2ID"
foreign-key="FK_Class1_Class2" />
</idbag>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<!--
vim:sw=2:ts=2:expandtab:fo=tcqro:ai:encoding=utf-8
-->
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="TestNHibernate.Domain"
namespace="TestNHibernate.Domain"
default-lazy="true"
default-cascade="none"
schema="dbo">
<class name="Class2">
<id name="ID">
<generator class="increment"/>
</id>
<version name="EntityVersion"/>
<idbag name="Class1List" table="Class1_Class2" cascade="none" lazy="true"
access="field.camelcase-underscore">
<collection-id column="ID" type="Guid">
<generator class="guid.comb" />
</collection-id>
<key column="Class2ID" foreign-key="FK_Class1_Class2" />
<many-to-many class="Class1" column="Class1ID"
foreign-key="FK_Class2_Class1" />
</idbag>
</class>
</hibernate-mapping>