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

future-architect / uroborosql / #743

28 Jun 2024 04:17PM UTC coverage: 90.988% (+0.5%) from 90.484%
#743

push

web-flow
add paramIfNotEmpty method (#318)

* v0.x to master merge

* fix nanoseconds diff (java8 to java11)

* eclipse cleanup and  optimize import

* eclipse format

* optimize Imports

* remove unused annotation

* library version up

* migrate v0.x to master
- update java version 8 to 11
- update junit4 to junit5
- library version update

* fix test failed

* remove unused annotation

* fixed bug

* use var

* fix java8 coding style

* Refactoring TransactionContextManager

* Refactoring SqlAgent

* 途中コミット

* fix testcase

* fix review

* fix javadoc comments

* merge v0.x PR

* cleanup code

* cleanup test code

* change build status badge

* - agent.query, update, proc, batch にそれぞれSupplierを引数にとるメソッドを追加
- SqlQuery.paramとSqlEntityUpdate.setにFunctionを受け取るメソッドを追加

* testcaseの整形

* - SqlFluent と ExtractionCondition の分離
- Arrays.asList -> List.of への変更
- テストの整形

* - v0.x系の不具合対応の追いつき
- ログ出力の整理

* - SqlKindの整理(ENTITY_XXXの追加)
- REPL_LOGの追加
- Deprecatedメソッドの削除(SqlAgent)
- SqlAgent, ExecutionContextでsetterをfluent APIに変更

* DB接続URLの修正

* add and fix testcases.

* add event testcases.

* fix typo

* add paramIfNotEmpty method and StringUtils rename ObjectUtils

* fix review comments.

* remove unused import

1695 of 1958 new or added lines in 97 files covered. (86.57%)

26 existing lines in 10 files now uncovered.

8249 of 9066 relevant lines covered (90.99%)

0.91 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/ExecutionContext.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
 * ExecutionContextインタフェース
24
 *
25
 * @author H.Sugimoto
26
 *
27
 */
28
public interface ExecutionContext
29
                extends TransformContext, SqlFluent<ExecutionContext>, ProcedureFluent<ExecutionContext> {
30

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

168
        /**
169
         * 列型の定義追加<br>
170
         *
171
         * @param column カラム番号
172
         * @param type {@link java.sql.Types}で表されるSQLの型
173
         * @return 自身のExecutionContext
174
         */
175
        ExecutionContext addDefineColumnType(int column, int type);
176

177
        /**
178
         * 列型の定義追加<br>
179
         *
180
         * @param column カラム番号
181
         * @param type {@link java.sql.SQLType}で表されるSQLの型
182
         * @return 自身のExecutionContext
183
         */
184
        default ExecutionContext addDefineColumnType(final int column, final SQLType type) {
185
                addDefineColumnType(column, type.getVendorTypeNumber());
×
NEW
186
                return this;
×
187
        }
188

189
        /**
190
         * 列型の定義情報を取得する
191
         * @return 列の型定義情報
192
         */
193
        Map<Integer, Integer> getDefineColumnTypes();
194

195
        /**
196
         * 結果セットの型の設定<BR>
197
         * {@link ResultSet#TYPE_FORWARD_ONLY}、{@link ResultSet#TYPE_SCROLL_INSENSITIVE}、
198
         * {@link ResultSet#TYPE_SCROLL_SENSITIVE} のうちいづれか 1 つ
199
         *
200
         * @param resultSetType 結果セットの型
201
         * @return 自身のExecutionContext
202
         */
203
        ExecutionContext setResultSetType(int resultSetType);
204

205
        /**
206
         * 結果セットの型の取得
207
         *
208
         * @return 結果セットの型
209
         */
210
        int getResultSetType();
211

212
        /**
213
         * 並行処理の種類の設定<BR>
214
         * {@link ResultSet#CONCUR_READ_ONLY} または {@link ResultSet#CONCUR_UPDATABLE}
215
         *
216
         * @param resultSetConcurrency 並行処理の種類
217
         * @return 自身のExecutionContext
218
         */
219
        ExecutionContext setResultSetConcurrency(int resultSetConcurrency);
220

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

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

235
        /**
236
         * 実行するSQLの種別を設定する
237
         *
238
         * @param sqlKind SQL種別
239
         * @return 自身のExecutionContext
240
         */
241
        ExecutionContext setSqlKind(SqlKind sqlKind);
242

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

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

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

263
        /**
264
         * 自動採番するキーカラム名の配列を設定する
265
         *
266
         * @param generatedKeyColumns 自動採番するキーカラム名の配列
267
         * @return 自身のExecutionContext
268
         */
269
        ExecutionContext 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
         * @return 自身のExecutionContext
290
         */
291
        ExecutionContext setGeneratedKeyValues(Object[] generatedKeyValues);
292

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

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

311
}
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