1
+ using System . Collections . Generic ;
2
+ using NHibernate . Engine ;
3
+
4
+ namespace NHibernate . Cfg . Loquacious
5
+ {
6
+ public interface INamedQueryDefinitionBuilder
7
+ {
8
+ bool IsCacheable { get ; set ; }
9
+ string CacheRegion { get ; set ; }
10
+ int FetchSize { get ; set ; }
11
+ int Timeout { get ; set ; }
12
+ FlushMode FlushMode { get ; set ; }
13
+ string Query { get ; set ; }
14
+ bool IsReadOnly { get ; set ; }
15
+ string Comment { get ; set ; }
16
+ CacheMode ? CacheMode { get ; set ; }
17
+ }
18
+
19
+ internal class NamedQueryDefinitionBuilder : INamedQueryDefinitionBuilder
20
+ {
21
+ private int fetchSize = - 1 ;
22
+ private int timeout = - 1 ;
23
+
24
+ public NamedQueryDefinitionBuilder ( )
25
+ {
26
+ FlushMode = FlushMode . Unspecified ;
27
+ }
28
+
29
+ #region INamedQueryDefinitionBuilder Members
30
+
31
+ public bool IsCacheable { get ; set ; }
32
+ public string CacheRegion { get ; set ; }
33
+
34
+ public int FetchSize
35
+ {
36
+ get { return fetchSize ; }
37
+ set
38
+ {
39
+ if ( value > 0 )
40
+ {
41
+ fetchSize = value ;
42
+ }
43
+ else
44
+ {
45
+ fetchSize = - 1 ;
46
+ }
47
+ }
48
+ }
49
+
50
+ public int Timeout
51
+ {
52
+ get { return timeout ; }
53
+ set
54
+ {
55
+ if ( value > 0 )
56
+ {
57
+ timeout = value ;
58
+ }
59
+ else
60
+ {
61
+ timeout = - 1 ;
62
+ }
63
+ }
64
+ }
65
+
66
+ public FlushMode FlushMode { get ; set ; }
67
+ public string Query { get ; set ; }
68
+ public bool IsReadOnly { get ; set ; }
69
+ public string Comment { get ; set ; }
70
+ public CacheMode ? CacheMode { get ; set ; }
71
+
72
+ #endregion
73
+
74
+ public NamedQueryDefinition Build ( )
75
+ {
76
+ return new NamedQueryDefinition ( Query , IsCacheable , CacheRegion , Timeout , FetchSize , FlushMode , CacheMode , IsReadOnly , Comment , new Dictionary < string , string > ( 1 ) ) ;
77
+ }
78
+ }
79
+ }
0 commit comments