• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

future-architect / uroborosql / #711

pending completion
#711

push

HidekiSugimoto189
[maven-release-plugin] prepare for next development iteration

7913 of 8776 relevant lines covered (90.17%)

0.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/jp/co/future/uroborosql/context/SqlContext.java
1
/**
2
 * Copyright (c) 2017-present, Future Corporation
3
 *
4
 * This source code is licensed under the MIT license found in the
5
 * LICENSE file in the root directory of this source tree.
6
 */
7
package jp.co.future.uroborosql.context;
8

9
import java.sql.CallableStatement;
10
import java.sql.PreparedStatement;
11
import java.sql.ResultSet;
12
import java.sql.SQLException;
13
import java.sql.SQLType;
14
import java.util.Map;
15
import java.util.function.Function;
16

17
import jp.co.future.uroborosql.enums.SqlKind;
18
import jp.co.future.uroborosql.fluent.ProcedureFluent;
19
import jp.co.future.uroborosql.fluent.SqlFluent;
20
import jp.co.future.uroborosql.parser.TransformContext;
21

22
/**
23
 * SQLコンテキストインタフェース
24
 *
25
 * @author H.Sugimoto
26
 *
27
 */
28
public interface SqlContext extends TransformContext, SqlFluent<SqlContext>, ProcedureFluent<SqlContext> {
29

30
        /**
31
         * 変換前SQL取得
32
         *
33
         * @return 変換前SQL
34
         */
35
        String getSql();
36

37
        /**
38
         * 変換前SQL設定
39
         *
40
         * @param sql 変換前SQL
41
         * @return 自身のSqlContext
42
         */
43
        SqlContext setSql(String sql);
44

45
        /**
46
         * SQL名取得
47
         *
48
         * @return SQLファイルのルートからの相対パス(ファイル拡張子なし)
49
         */
50
        String getSqlName();
51

52
        /**
53
         * SQL名設定
54
         *
55
         * @param sqlName SQLファイルのルートからの相対パス(ファイル拡張子なし)を指定
56
         * @return 自身のSqlContext
57
         */
58
        SqlContext setSqlName(String sqlName);
59

60
        /**
61
         * SQL文を識別するための文字列を取得
62
         *
63
         * @return SQL識別子
64
         */
65
        String getSqlId();
66

67
        /**
68
         * SQL文を識別するための文字列を設定
69
         *
70
         * @param sqlId SQL識別子
71
         * @return 自身のSqlContext
72
         */
73
        SqlContext setSqlId(String sqlId);
74

75
        /**
76
         * SQLを実行するスキーマを取得
77
         *
78
         * @return スキーマ
79
         */
80
        String getSchema();
81

82
        /**
83
         * SQLを実行するスキーマを設定
84
         *
85
         * @param schema スキーマ
86
         * @return 自身のSqlContext
87
         */
88
        SqlContext setSchema(String schema);
89

90
        /**
91
         * 最大リトライ回数 を取得する
92
         *
93
         * @return 最大リトライ回数
94
         */
95
        int getMaxRetryCount();
96

97
        /**
98
         * 最大リトライ回数 を設定する
99
         *
100
         * @param maxRetryCount 最大リトライ回数
101
         * @return 自身のSqlContext
102
         */
103
        SqlContext setMaxRetryCount(int maxRetryCount);
104

105
        /**
106
         * リトライ待機時間(ms) を取得する
107
         *
108
         * @return リトライ待機時間(ms)
109
         */
110
        int getRetryWaitTime();
111

112
        /**
113
         * リトライ待機時間(ms) を設定する
114
         *
115
         * @param retryWaitTime リトライ待機時間(ms)
116
         * @return 自身のSqlContext
117
         */
118
        SqlContext setRetryWaitTime(int retryWaitTime);
119

120
        /**
121
         * ステートメントにパラメータをバインドする
122
         *
123
         * @param preparedStatement バインドを行うステートメント
124
         * @throws SQLException SQL例外
125
         */
126
        void bindParams(PreparedStatement preparedStatement) throws SQLException;
127

128
        /**
129
         * ステートメントにバッチ用のパラメータをバインドする
130
         *
131
         * @param preparedStatement バインドを行うステートメント
132
         * @throws SQLException SQL例外
133
         */
134
        void bindBatchParams(PreparedStatement preparedStatement) throws SQLException;
135

136
        /**
137
         * 出力パラメータの取得
138
         *
139
         * @param callableStatement コーラブルステートメント
140
         * @return 出力パラメータのMap
141
         * @throws SQLException SQL例外
142
         */
143
        Map<String, Object> getOutParams(CallableStatement callableStatement) throws SQLException;
144

145
        /**
146
         * これまでに追加されたパラメータ群をバッチパラメータに格納する
147
         *
148
         * @return 自身のSqlContext
149
         */
150
        SqlContext addBatch();
151

152
        /**
153
         * これまでに追加されたパラメータ群をバッチパラメータから削除する
154
         *
155
         * @return 自身のSqlContext
156
         */
157
        SqlContext clearBatch();
158

159
        /**
160
         * addBatchされた回数を取得する
161
         * @return バッチ回数
162
         */
163
        int batchCount();
164

165
        /**
166
         * 自動パラメータバインド関数(query用)の受け入れ
167
         */
168
        void acceptQueryAutoParameterBinder();
169

170
        /**
171
         * 自動パラメータバインド関数(update/batch/proc用)の受け入れ
172
         */
173
        void acceptUpdateAutoParameterBinder();
174

175
        /**
176
         * 列型の定義追加<br>
177
         *
178
         * @param column カラム番号
179
         * @param type {@link java.sql.Types}で表されるSQLの型
180
         */
181
        void addDefineColumnType(int column, int type);
182

183
        /**
184
         * 列型の定義追加<br>
185
         *
186
         * @param column カラム番号
187
         * @param type {@link java.sql.SQLType}で表されるSQLの型
188
         */
189
        default void addDefineColumnType(final int column, final SQLType type) {
190
                addDefineColumnType(column, type.getVendorTypeNumber());
×
191
        }
×
192

193
        /**
194
         * 列型の定義情報を取得する
195
         * @return 列の型定義情報
196
         */
197
        Map<Integer, Integer> getDefineColumnTypes();
198

199
        /**
200
         * 結果セットの型の設定<BR>
201
         * {@link ResultSet#TYPE_FORWARD_ONLY}、{@link ResultSet#TYPE_SCROLL_INSENSITIVE}、
202
         * {@link ResultSet#TYPE_SCROLL_SENSITIVE} のうちいづれか 1 つ
203
         *
204
         * @param resultSetType 結果セットの型
205
         */
206
        void setResultSetType(int resultSetType);
207

208
        /**
209
         * 結果セットの型の取得
210
         *
211
         * @return 結果セットの型
212
         */
213
        int getResultSetType();
214

215
        /**
216
         * 並行処理の種類の設定<BR>
217
         * {@link ResultSet#CONCUR_READ_ONLY} または {@link ResultSet#CONCUR_UPDATABLE}
218
         *
219
         * @param resultSetConcurrency 並行処理の種類
220
         */
221
        void setResultSetConcurrency(int resultSetConcurrency);
222

223
        /**
224
         * 並行処理の種類の取得
225
         *
226
         * @return 並行処理の種類
227
         */
228
        int getResultSetConcurrency();
229

230
        /**
231
         * 実行するSQLの種別を取得する
232
         *
233
         * @return SQL種別
234
         */
235
        SqlKind getSqlKind();
236

237
        /**
238
         * 実行するSQLの種別を設定する
239
         *
240
         * @param sqlKind SQL種別
241
         */
242
        void setSqlKind(SqlKind sqlKind);
243

244
        /**
245
         * コンテキストが保持する属性を取得する
246
         * @return コンテキスト属性情報
247
         */
248
        Map<String, Object> contextAttrs();
249

250
        /**
251
         * バインドパラメータの文字列表現を返す
252
         *
253
         * @return バインドパラメータの文字列表現
254
         */
255
        String formatParams();
256

257
        /**
258
         * 自動採番するキーカラム名の配列を取得する
259
         *
260
         * @return 自動採番するキーカラム名の配列
261
         */
262
        String[] getGeneratedKeyColumns();
263

264
        /**
265
         * 自動採番するキーカラム名の配列を設定する
266
         *
267
         * @param generatedKeyColumns 自動採番するキーカラム名の配列
268
         */
269
        void setGeneratedKeyColumns(String[] generatedKeyColumns);
270

271
        /**
272
         * 自動採番するキーカラム値の配列を取得する
273
         *
274
         * @return 自動採番するキーカラム値の配列
275
         */
276
        Object[] getGeneratedKeyValues();
277

278
        /**
279
         * 自動採番するキーカラム名の配列に値が設定されているか
280
         *
281
         * @return 値が設定されている場合<code>true</code>
282
         */
283
        boolean hasGeneratedKeyColumns();
284

285
        /**
286
         * 自動採番するキーカラム値の配列を設定する
287
         *
288
         * @param generatedKeyValues 自動採番するキーカラム値の配列
289
         */
290
        void setGeneratedKeyValues(Object[] generatedKeyValues);
291

292
        /**
293
         * 更新処理実行時に通常の更新SQL発行の代わりに移譲する処理を取得する.<br>
294
         * デフォルト実装は<code>null</code> を返却する. 必要に応じて子クラスでオーバーライドすること.
295
         *
296
         * @return 通常の更新SQL発行の代わりに行う疑似動作. <code>null</code> が返る場合は通常の更新処理を行う.
297
         */
298
        default Function<SqlContext, Integer> getUpdateDelegate() {
299
                return null;
×
300
        }
301

302
        /**
303
         * 更新処理実行時に通常の更新SQL発行の代わりに移譲する処理を設定する.
304
         *
305
         * @param updateDelegate 通常の更新SQL発行の代わりに移譲する処理. <code>null</code> を設定した場合は通常の更新処理を行う.
306
         * @return 自身のSqlContext
307
         */
308
        SqlContext setUpdateDelegate(Function<SqlContext, Integer> updateDelegate);
309

310
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc