On Wednesday, 15 March 2017 17:33:08 UTC+2, Ricardo Peres wrote:
>
> Do you have a unit test that can demonstrate this problem?
> It should be as simple as possible, with only the base minimum to
> demonstrate this.
>
> RP
>
>>
>>>
Thanks and yes, I attach a git patch that adds a unit test to replicate the
issue. I also pushed this to my fork
at
https://github.com/igitur/nhibernate-core/tree/batch-insert-using-stateless-session
Francois
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/NHibernate.Test/NHSpecificTest/NH2241/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2241/Fixture.cs
new file mode 100644
index 0000000..c770af1
--- /dev/null
+++ b/src/NHibernate.Test/NHSpecificTest/NH2241/Fixture.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NHibernate.Criterion;
+using NUnit.Framework;
+using System.Collections;
+namespace NHibernate.Test.NHSpecificTest.NH2241
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ protected override void OnSetUp()
+ {
+ using(var session=OpenSession())
+ {
+ using (var tran = session.BeginTransaction())
+ {
+ var country = new Country() {CountryCode = "SE", CountryName = "Sweden"};
+ session.Save(country);
+ tran.Commit();
+ }
+ }
+ }
+ protected override void OnTearDown()
+ {
+ using (var session = OpenSession())
+ using (var tran = session.BeginTransaction())
+ {
+ session.Delete("from Country");
+ session.Delete("from User");
+ tran.Commit();
+ }
+ }
+
+ [Test]
+ public void CanInsertUsingStatelessEvenWhenAssociatedEntityHasCacheStategy()
+ {
+ using(var ss= sessions.OpenStatelessSession())
+ {
+ using (var tx = ss.BeginTransaction())
+ {
+ var user = new User();
+ user.Country = new Country() {CountryCode = "SE", CountryName = "Sweden"};
+
+ ss.Insert(user);
+ tx.Commit();
+ }
+
+ }
+ }
+ }
+}
diff --git a/src/NHibernate.Test/NHSpecificTest/NH2241/Mappings.hbm.xml b/src/NHibernate.Test/NHSpecificTest/NH2241/Mappings.hbm.xml
new file mode 100644
index 0000000..39cd191
--- /dev/null
+++ b/src/NHibernate.Test/NHSpecificTest/NH2241/Mappings.hbm.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH2241">
+
+ <class name="User" table="Users">
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+
+ <many-to-one name="Country" column="CountryCode" cascade="none" />
+ </class>
+
+ <class name="Country">
+ <cache region="ShortTerm" usage="read-write" />
+
+ <id name="CountryCode">
+ <generator class="assigned"/>
+ </id>
+
+ <property name="CountryName" />
+
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
diff --git a/src/NHibernate.Test/NHSpecificTest/NH2241/Model.cs b/src/NHibernate.Test/NHSpecificTest/NH2241/Model.cs
new file mode 100644
index 0000000..1fcdba8
--- /dev/null
+++ b/src/NHibernate.Test/NHSpecificTest/NH2241/Model.cs
@@ -0,0 +1,27 @@
+using System;
+
+namespace NHibernate.Test.NHSpecificTest.NH2241
+{
+ public class User
+ {
+ public virtual int Id { get; set; }
+
+ public virtual Country Country { get; set; }
+ }
+
+ public class Country
+ {
+ public virtual string CountryCode
+ {
+ get;
+ set;
+ }
+
+ public virtual string CountryName
+ {
+ get;
+ set;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/src/NHibernate.Test/NHibernate.Test.csproj b/src/NHibernate.Test/NHibernate.Test.csproj
index 8fae873..88a7c54 100644
--- a/src/NHibernate.Test/NHibernate.Test.csproj
+++ b/src/NHibernate.Test/NHibernate.Test.csproj
@@ -737,6 +737,8 @@
<Compile Include="NHSpecificTest\EntityWithUserTypeCanHaveLinqGenerators\Fixture.cs" />
<Compile Include="NHSpecificTest\EntityWithUserTypeCanHaveLinqGenerators\FooExample.cs" />
<Compile Include="NHSpecificTest\EntityWithUserTypeCanHaveLinqGenerators\IExample.cs" />
+ <Compile Include="NHSpecificTest\NH2241\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH2241\Model.cs" />
<Compile Include="NHSpecificTest\NH3950\Entity.cs" />
<Compile Include="NHSpecificTest\NH3950\Fixture.cs" />
<Compile Include="NHSpecificTest\NH3952\Entity.cs" />
@@ -3208,6 +3210,7 @@
<EmbeddedResource Include="NHSpecificTest\NH1291AnonExample\Mappings.hbm.xml" />
</ItemGroup>
<ItemGroup>
+ <EmbeddedResource Include="NHSpecificTest\NH2241\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH3950\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH3952\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2204\Mappings.hbm.xml" />