File tree Expand file tree Collapse file tree 4 files changed +107
-0
lines changed Expand file tree Collapse file tree 4 files changed +107
-0
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Text ;
4
+ using NHibernate . Criterion ;
5
+ using NUnit . Framework ;
6
+ using System . Collections ;
7
+ namespace NHibernate . Test . NHSpecificTest . NH2241
8
+ {
9
+ [ TestFixture ]
10
+ public class Fixture : BugTestCase
11
+ {
12
+ protected override void OnSetUp ( )
13
+ {
14
+ using ( var session = OpenSession ( ) )
15
+ {
16
+ using ( var tran = session . BeginTransaction ( ) )
17
+ {
18
+ var country = new Country ( ) { CountryCode = "SE" , CountryName = "Sweden" } ;
19
+ session . Save ( country ) ;
20
+ tran . Commit ( ) ;
21
+ }
22
+ }
23
+ }
24
+ protected override void OnTearDown ( )
25
+ {
26
+ using ( var session = OpenSession ( ) )
27
+ using ( var tran = session . BeginTransaction ( ) )
28
+ {
29
+ session . Delete ( "from Country" ) ;
30
+ session . Delete ( "from User" ) ;
31
+ tran . Commit ( ) ;
32
+ }
33
+ }
34
+
35
+ [ Test ]
36
+ public void CanInsertUsingStatelessEvenWhenAssociatedEntityHasCacheStategy ( )
37
+ {
38
+ using ( var ss = Sfi . OpenStatelessSession ( ) )
39
+ {
40
+ using ( var tx = ss . BeginTransaction ( ) )
41
+ {
42
+ var user = new User ( ) ;
43
+ user . Country = new Country ( ) { CountryCode = "SE" , CountryName = "Sweden" } ;
44
+
45
+ ss . Insert ( user ) ;
46
+ tx . Commit ( ) ;
47
+ }
48
+
49
+ }
50
+ }
51
+ }
52
+ }
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" utf-8" ?>
2
+ <hibernate-mapping xmlns =" urn:nhibernate-mapping-2.2"
3
+ assembly=" NHibernate.Test"
4
+ namespace=" NHibernate.Test.NHSpecificTest.NH2241" >
5
+
6
+ <class name =" User" table =" Users" >
7
+ <id name =" Id" >
8
+ <generator class =" native" />
9
+ </id >
10
+
11
+ <many-to-one name =" Country" column =" CountryCode" cascade =" none" />
12
+ </class >
13
+
14
+ <class name =" Country" >
15
+ <cache region =" ShortTerm" usage =" read-write" />
16
+
17
+ <id name =" CountryCode" >
18
+ <generator class =" assigned" />
19
+ </id >
20
+
21
+ <property name =" CountryName" />
22
+
23
+ </class >
24
+
25
+ </hibernate-mapping >
Original file line number Diff line number Diff line change
1
+ using System ;
2
+
3
+ namespace NHibernate . Test . NHSpecificTest . NH2241
4
+ {
5
+ public class User
6
+ {
7
+ public virtual int Id { get ; set ; }
8
+
9
+ public virtual Country Country { get ; set ; }
10
+ }
11
+
12
+ public class Country
13
+ {
14
+ public virtual string CountryCode
15
+ {
16
+ get ;
17
+ set ;
18
+ }
19
+
20
+ public virtual string CountryName
21
+ {
22
+ get ;
23
+ set ;
24
+ }
25
+
26
+ }
27
+ }
Original file line number Diff line number Diff line change 760
760
<Compile Include =" NHSpecificTest\EntityWithUserTypeCanHaveLinqGenerators\Fixture.cs" />
761
761
<Compile Include =" NHSpecificTest\EntityWithUserTypeCanHaveLinqGenerators\FooExample.cs" />
762
762
<Compile Include =" NHSpecificTest\EntityWithUserTypeCanHaveLinqGenerators\IExample.cs" />
763
+ <Compile Include =" NHSpecificTest\NH2241\Fixture.cs" />
764
+ <Compile Include =" NHSpecificTest\NH2241\Model.cs" />
763
765
<Compile Include =" Insertordering\NH3931Entities.cs" />
764
766
<Compile Include =" NHSpecificTest\NH4004\Entity.cs" />
765
767
<Compile Include =" NHSpecificTest\NH4004\Fixture.cs" />
3284
3286
<EmbeddedResource Include =" NHSpecificTest\NH1291AnonExample\Mappings.hbm.xml" />
3285
3287
</ItemGroup >
3286
3288
<ItemGroup >
3289
+ <EmbeddedResource Include =" NHSpecificTest\NH2241\Mappings.hbm.xml" />
3287
3290
<EmbeddedResource Include =" Futures\Mappings.hbm.xml" />
3288
3291
<EmbeddedResource Include =" SessionBuilder\Mappings.hbm.xml" />
3289
3292
<EmbeddedResource Include =" IdTest\IdentityClass.hbm.xml" />
You can’t perform that action at this time.
0 commit comments