File tree Expand file tree Collapse file tree 5 files changed +272
-388
lines changed
NHibernate/Persister/Entity Expand file tree Collapse file tree 5 files changed +272
-388
lines changed Original file line number Diff line number Diff line change
1
+ namespace NHibernate . Test . NHSpecificTest . NH3372
2
+ {
3
+ public class Entity
4
+ {
5
+ public int Id { get ; set ; }
6
+ public string ShardId { get ; set ; }
7
+ public string Content { get ; set ; }
8
+ }
9
+ }
Original file line number Diff line number Diff line change
1
+ using NUnit . Framework ;
2
+
3
+ namespace NHibernate . Test . NHSpecificTest . NH3372
4
+ {
5
+ [ TestFixture ]
6
+ public class Fixture : BugTestCase
7
+ {
8
+ protected override bool AppliesTo ( Dialect . Dialect dialect )
9
+ {
10
+ return dialect is NHibernate . Dialect . MsSql2000Dialect ;
11
+ }
12
+
13
+ [ Test ]
14
+ public void CanGeneratePropertyOnInsertOfEntityWithCustomLoader ( )
15
+ {
16
+ using ( var session = OpenSession ( ) )
17
+ using ( session . BeginTransaction ( ) )
18
+ {
19
+ var entity = new Entity { Content = "Some text" } ;
20
+ session . Save ( entity ) ;
21
+ session . Flush ( ) ;
22
+
23
+ Assert . That ( entity . ShardId , Is . Not . Null & Has . Length . GreaterThan ( 0 ) ) ;
24
+ }
25
+ }
26
+
27
+ [ Test ]
28
+ public void CanGeneratePropertyOnUpdateOfEntityWithCustomLoader ( )
29
+ {
30
+ using ( var session = OpenSession ( ) )
31
+ using ( session . BeginTransaction ( ) )
32
+ {
33
+ var entity = new Entity { Content = "Some text" } ;
34
+ session . Save ( entity ) ;
35
+ session . Flush ( ) ;
36
+
37
+ entity . ShardId = null ;
38
+ entity . Content = "Some other text" ;
39
+ session . Update ( entity ) ;
40
+ session . Flush ( ) ;
41
+
42
+ Assert . That ( entity . ShardId , Is . Not . Null & Has . Length . GreaterThan ( 0 ) ) ;
43
+ }
44
+ }
45
+
46
+ }
47
+ }
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.NH3372" >
5
+
6
+ <class name =" Entity" table =" entity" lazy =" false" >
7
+ <id name =" Id" column =" id" generator =" native" />
8
+ <property name =" ShardId" generated =" always" insert =" false" update =" false" />
9
+ <property name =" Content" column =" content" />
10
+ <loader query-ref =" LoadEntity" />
11
+ </class >
12
+
13
+ <sql-query name =" LoadEntity" xml : space =" preserve" >
14
+ <return class =" Entity" alias =" e" />
15
+ SELECT id AS {e.Id}
16
+ , DB_NAME() AS {e.ShardId}
17
+ , content AS {e.Content}
18
+ FROM entity
19
+ WHERE id = ?
20
+ </sql-query >
21
+ </hibernate-mapping >
You can’t perform that action at this time.
0 commit comments