1
|
|
|
2
|
|
#region Apache Notice
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
|
18
|
|
|
19
|
|
|
20
|
|
|
21
|
|
|
22
|
|
|
23
|
|
|
24
|
|
|
25
|
|
#endregion
|
26
|
|
|
27
|
|
#region Imports
|
28
|
|
using System;
|
29
|
|
|
30
|
|
using IBatisNet.Common;
|
31
|
|
using IBatisNet.DataMapper.Configuration.Statements;
|
32
|
|
using IBatisNet.DataMapper.Scope;
|
33
|
|
#endregion
|
34
|
|
|
35
|
|
|
36
|
|
namespace IBatisNet.DataMapper.Configuration.Sql.Static
|
37
|
|
{
|
38
|
|
|
39
|
|
|
40
|
|
|
41
|
|
public class ProcedureSql : ISql
|
42
|
|
{
|
43
|
|
#region Fields
|
44
|
|
|
45
|
|
private IStatement _statement = null ;
|
46
|
|
private PreparedStatement _preparedStatement = null ;
|
47
|
|
private string _sqlStatement = string.Empty;
|
48
|
|
private object _synRoot = new Object();
|
49
|
|
|
50
|
|
#endregion
|
51
|
|
|
52
|
|
#region Constructor (s) / Destructor
|
53
|
|
|
54
|
|
|
55
|
|
|
56
|
|
|
57
|
|
|
58
|
680
|
public ProcedureSql(string sqlStatement, IStatement statement)
|
59
|
|
{
|
60
|
680
|
_sqlStatement = sqlStatement;
|
61
|
680
|
_statement = statement;
|
62
|
|
}
|
63
|
|
#endregion
|
64
|
|
|
65
|
|
#region ISql Members
|
66
|
|
|
67
|
|
|
68
|
|
|
69
|
|
|
70
|
|
|
71
|
|
|
72
|
|
|
73
|
7
|
public RequestScope GetRequestScope(object parameterObject, IDalSession session)
|
74
|
|
{
|
75
|
7
|
RequestScope request = new RequestScope();
|
76
|
|
|
77
|
7
|
request.ParameterMap = _statement.ParameterMap;
|
78
|
7
|
request.ResultMap = _statement.ResultMap;
|
79
|
7
|
request.PreparedStatement = BuildPreparedStatement(session, request, _sqlStatement);
|
80
|
|
|
81
|
7
|
return request;
|
82
|
|
}
|
83
|
|
|
84
|
|
|
85
|
|
|
86
|
|
|
87
|
|
|
88
|
|
|
89
|
|
|
90
|
7
|
public PreparedStatement BuildPreparedStatement(IDalSession session, RequestScope request, string commandText)
|
91
|
|
{
|
92
|
7
|
if ( _preparedStatement == null )
|
93
|
|
{
|
94
|
6
|
lock(_synRoot)
|
95
|
|
{
|
96
|
6
|
if (_preparedStatement==null)
|
97
|
|
{
|
98
|
6
|
PreparedStatementFactory factory = new PreparedStatementFactory( session, request, _statement, commandText);
|
99
|
6
|
_preparedStatement = factory.Prepare();
|
100
|
|
}
|
101
|
|
}
|
102
|
|
}
|
103
|
7
|
return _preparedStatement;
|
104
|
|
}
|
105
|
|
|
106
|
|
#endregion
|
107
|
|
}
|
108
|
|
}
|
109
|
|
|