• 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

83.33
/src/main/java/jp/co/future/uroborosql/dialect/OracleDialect.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.dialect;
8

9
import java.util.Collections;
10
import java.util.HashSet;
11
import java.util.List;
12
import java.util.Set;
13
import java.util.stream.Collectors;
14

15
import jp.co.future.uroborosql.connection.ConnectionSupplier;
16

17
/**
18
 * Oracle共通の抽象Dialect
19
 *
20
 * @author H.Sugimoto
21
 */
22
public abstract class OracleDialect extends AbstractDialect {
23
        /**
24
         * 悲観ロックのErrorCode もしくは SqlState. Oracleの場合errorCodeで判定する.
25
         * <pre>ORA-00054: リソース・ビジー。NOWAITが指定されているか、タイムアウトしました</pre>
26
         * <pre>ORA-30006: リソース・ビジー; WAITタイムアウトの期限に達しました。</pre>
27
         */
28
        private static final Set<String> pessimisticLockingErrorCodes = Collections
1✔
29
                        .unmodifiableSet(new HashSet<>(List.of("54", "30006")));
1✔
30

31
        /**
32
         * コンストラクタ
33
         * @param escapeChar like検索時のエスケープ文字
34
         * @param wildcards like検索時のワイルドカード文字配列
35
         */
36
        protected OracleDialect(final char escapeChar, final char[] wildcards) {
37
                super(escapeChar, wildcards);
1✔
38
        }
1✔
39

40
        /**
41
         * {@inheritDoc}
42
         *
43
         * @see jp.co.future.uroborosql.dialect.Dialect#getDatabaseName()
44
         */
45
        @Override
46
        public String getDatabaseName() {
47
                return "Oracle";
1✔
48
        }
49

50
        /**
51
         * {@inheritDoc}
52
         *
53
         * @see jp.co.future.uroborosql.dialect.Dialect#supportsNullValuesOrdering()
54
         */
55
        @Override
56
        public boolean supportsNullValuesOrdering() {
57
                return true;
1✔
58
        }
59

60
        /**
61
         * {@inheritDoc}
62
         *
63
         * @see jp.co.future.uroborosql.dialect.Dialect#supportsIdentity()
64
         */
65
        @Override
66
        public boolean supportsIdentity() {
67
                return false;
1✔
68
        }
69

70
        /**
71
         * {@inheritDoc}
72
         *
73
         * @see jp.co.future.uroborosql.dialect.Dialect#supportsOptimizerHints()
74
         */
75
        @Override
76
        public boolean supportsOptimizerHints() {
77
                return true;
1✔
78
        }
79

80
        /**
81
         * {@inheritDoc}
82
         *
83
         * @see jp.co.future.uroborosql.dialect.Dialect#getSequenceNextValSql(java.lang.String)
84
         */
85
        @Override
86
        public String getSequenceNextValSql(final String sequenceName) {
87
                return sequenceName + ".nextval";
1✔
88
        }
89

90
        /**
91
         * {@inheritDoc}
92
         *
93
         * @see jp.co.future.uroborosql.dialect.Dialect#accept(jp.co.future.uroborosql.connection.ConnectionSupplier)
94
         */
95
        @Override
96
        public boolean accept(final ConnectionSupplier supplier) {
97
                if (supplier == null) {
1✔
98
                        return false;
×
99
                }
100

101
                var parts = supplier.getDatabaseName().split("-", 2);
1✔
102
                var databaseName = parts[0];
1✔
103

104
                if (!databaseName.startsWith(getDatabaseName())) {
1✔
105
                        return false;
1✔
106
                }
107

108
                var databaseVersion = parts[1];
1✔
109

110
                try {
111
                        var majorVersion = Integer.parseInt(databaseVersion.substring(0, databaseVersion.indexOf(".")));
1✔
112
                        return isTargetVersion(majorVersion);
1✔
NEW
113
                } catch (NumberFormatException ex) {
×
114
                        return false;
×
115
                }
116
        }
117

118
        /**
119
         * 対象のOracleバージョンかどうかを判定する
120
         *
121
         * @param majorVersion コネクションから取得したメジャーバージョン
122
         * @return 対象のバージョンの場合<code>true</code>
123
         */
124
        protected abstract boolean isTargetVersion(int majorVersion);
125

126
        /**
127
         * {@inheritDoc}
128
         *
129
         * @see jp.co.future.uroborosql.dialect.Dialect#getModLiteral(java.lang.String, java.lang.String)
130
         */
131
        @Override
132
        public String getModLiteral(final String dividend, final String divisor) {
133
                return "MOD(" + dividend + ", " + divisor + ")";
×
134
        }
135

136
        /**
137
         * {@inheritDoc}
138
         *
139
         * @see jp.co.future.uroborosql.dialect.Dialect#addOptimizerHints(java.lang.StringBuilder, java.util.List)
140
         */
141
        @Override
142
        public StringBuilder addOptimizerHints(final StringBuilder sql, final List<String> hints) {
143
                var hintStr = "$1 /*+ " + hints.stream().collect(Collectors.joining(" ")) + " */";
1✔
144
                return new StringBuilder(sql.toString().replaceFirst("(SELECT( /\\*.+\\*/)*)", hintStr));
1✔
145
        }
146

147
        /**
148
         * {@inheritDoc}
149
         *
150
         * @see jp.co.future.uroborosql.dialect.Dialect#getPessimisticLockingErrorCodes()
151
         */
152
        @Override
153
        public Set<String> getPessimisticLockingErrorCodes() {
154
                return pessimisticLockingErrorCodes;
1✔
155
        }
156
}
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