• 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

86.67
/src/main/java/jp/co/future/uroborosql/SqlEntityUpdateImpl.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;
8

9
import java.sql.SQLException;
10
import java.sql.SQLType;
11
import java.util.function.Supplier;
12

13
import jp.co.future.uroborosql.context.ExecutionContext;
14
import jp.co.future.uroborosql.exception.EntitySqlRuntimeException;
15
import jp.co.future.uroborosql.fluent.SqlEntityUpdate;
16
import jp.co.future.uroborosql.mapping.EntityHandler;
17
import jp.co.future.uroborosql.mapping.TableMetadata;
18
import jp.co.future.uroborosql.utils.CaseFormat;
19

20
/**
21
 * SqlEntityQuery実装
22
 *
23
 * @param <E> Entity型
24
 * @author ota
25
 */
26
final class SqlEntityUpdateImpl<E> extends AbstractExtractionCondition<SqlEntityUpdate<E>>
27
                implements SqlEntityUpdate<E> {
28
        /** エンティティハンドラー */
29
        private final EntityHandler<?> entityHandler;
30

31
        /**
32
         * Constructor
33
         *
34
         * @param agent SqlAgent
35
         * @param entityHandler EntityHandler
36
         * @param tableMetadata TableMetadata
37
         * @param context ExecutionContext
38
         */
39
        SqlEntityUpdateImpl(final SqlAgent agent, final EntityHandler<?> entityHandler,
40
                        final TableMetadata tableMetadata, final ExecutionContext context) {
41
                super(agent, tableMetadata, context);
1✔
42
                this.entityHandler = entityHandler;
1✔
43
        }
1✔
44

45
        /**
46
         * {@inheritDoc}
47
         *
48
         * @see jp.co.future.uroborosql.fluent.SqlEntityUpdate#count()
49
         */
50
        @Override
51
        public int count() {
52
                try {
53
                        context().setSql(new StringBuilder(context().getSql()).append(getWhereClause()).toString());
1✔
54
                        return this.entityHandler.doUpdate(agent(), context(), null);
1✔
NEW
55
                } catch (final SQLException ex) {
×
NEW
56
                        throw new EntitySqlRuntimeException(context().getSqlKind(), ex);
×
57
                }
58
        }
59

60
        /**
61
         * {@inheritDoc}
62
         *
63
         * @see jp.co.future.uroborosql.fluent.SqlEntityUpdate#set(java.lang.String, java.lang.Object)
64
         */
65
        @Override
66
        public <V> SqlEntityUpdate<E> set(final String col, final V value) {
67
                context().param(CaseFormat.CAMEL_CASE.convert(col), value);
1✔
68
                return this;
1✔
69
        }
70

71
        /**
72
         * {@inheritDoc}
73
         *
74
         * @see jp.co.future.uroborosql.fluent.SqlEntityUpdate#set(java.lang.String, java.util.function.Supplier)
75
         */
76
        @Override
77
        public <V> SqlEntityUpdate<E> set(final String col, final Supplier<V> supplier) {
78
                context().param(CaseFormat.CAMEL_CASE.convert(col), supplier);
1✔
79
                return this;
1✔
80
        }
81

82
        /**
83
         * {@inheritDoc}
84
         *
85
         * @see jp.co.future.uroborosql.fluent.SqlEntityUpdate#set(java.lang.String, java.lang.Object, int)
86
         */
87
        @Override
88
        public <V> SqlEntityUpdate<E> set(final String col, final V value, final int sqlType) {
89
                context().param(CaseFormat.CAMEL_CASE.convert(col), value, sqlType);
1✔
90
                return this;
1✔
91
        }
92

93
        /**
94
         * {@inheritDoc}
95
         *
96
         * @see jp.co.future.uroborosql.fluent.SqlEntityUpdate#set(java.lang.String, java.lang.Object, java.sql.SQLType)
97
         */
98
        @Override
99
        public <V> SqlEntityUpdate<E> set(final String col, final V value, final SQLType sqlType) {
100
                context().param(CaseFormat.CAMEL_CASE.convert(col), value, sqlType);
1✔
101
                return this;
1✔
102
        }
103
}
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