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

future-architect / uroborosql / #764

13 Aug 2024 03:26PM UTC coverage: 91.218% (+0.02%) from 91.197%
#764

Pull #331

HidekiSugimoto189
add oracle v12-23 and Mariadb 5,10 dialect
Pull Request #331: add oracle v12-23 and Mariadb 5,10 dialect

43 of 46 new or added lines in 8 files covered. (93.48%)

288 existing lines in 22 files now uncovered.

8787 of 9633 relevant lines covered (91.22%)

0.91 hits per line

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

82.76
/src/main/java/jp/co/future/uroborosql/event/subscriber/DebugEventSubscriber.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.event.subscriber;
8

9
import java.sql.SQLException;
10

11
import org.slf4j.Logger;
12
import org.slf4j.LoggerFactory;
13

14
import jp.co.future.uroborosql.event.AfterBeginTransactionEvent;
15
import jp.co.future.uroborosql.event.AfterGetOutParameterEvent;
16
import jp.co.future.uroborosql.event.AfterSqlBatchEvent;
17
import jp.co.future.uroborosql.event.AfterSqlQueryEvent;
18
import jp.co.future.uroborosql.event.AfterSqlUpdateEvent;
19
import jp.co.future.uroborosql.event.BeforeEndTransactionEvent;
20
import jp.co.future.uroborosql.event.BeforeSetParameterEvent;
21

22
/**
23
 * デバッグログを出力するEventSubscriber
24
 *
25
 * @author H.Sugimoto
26
 * @since v1.0.0
27
 */
28
public class DebugEventSubscriber extends EventSubscriber {
1✔
29
        /** ロガー */
30
        private static final Logger EVENT_LOG = LoggerFactory.getLogger("jp.co.future.uroborosql.event.debug");
1✔
31

32
        @Override
33
        public void initialize() {
34
                afterBeginTransactionListener(this::afterBeginTransaction);
1✔
35
                beforeEndTransactionListener(this::beforeEndTransaction);
1✔
36
                beforeSetParameterListener(this::beforeSetParameter);
1✔
37
                afterGetOutParameterListener(this::afterGetOutParameter);
1✔
38
                afterSqlQueryListener(this::afterSqlQuery);
1✔
39
                afterSqlUpdateListener(this::afterSqlUpdate);
1✔
40
                afterSqlBatchListener(this::afterSqlBatch);
1✔
41
        }
1✔
42

43
        void afterBeginTransaction(final AfterBeginTransactionEvent evt) {
44
                if (EVENT_LOG.isDebugEnabled()) {
1✔
45
                        try {
46
                                EVENT_LOG.debug("Begin Transaction - connection:{}, requiredNew:{}, transactionLevel:{}, occurredOn:{}",
1✔
47
                                                evt.getTransactionContext().getConnection(),
1✔
48
                                                evt.isRequiredNew(),
1✔
49
                                                evt.getTransactionLevel(),
1✔
50
                                                evt.occurredOn());
1✔
51
                        } catch (SQLException ex) {
×
52
                                EVENT_LOG.error(ex.getMessage(), ex);
×
53
                        }
1✔
54
                }
55
        }
1✔
56

57
        void beforeEndTransaction(final BeforeEndTransactionEvent evt) {
58
                if (EVENT_LOG.isDebugEnabled()) {
1✔
59
                        try {
60
                                EVENT_LOG.debug(
1✔
61
                                                "End Transaction - connection:{}, requiredNew:{}, transactionLevel:{}, result:{}, occurredOn:{}",
62
                                                evt.getTransactionContext().getConnection(),
1✔
63
                                                evt.isRequiredNew(),
1✔
64
                                                evt.getTransactionLevel(),
1✔
65
                                                evt.getResult(),
1✔
66
                                                evt.occurredOn());
1✔
67
                        } catch (SQLException ex) {
×
68
                                EVENT_LOG.error(ex.getMessage(), ex);
×
69
                        }
1✔
70
                }
71
        }
1✔
72

73
        void beforeSetParameter(final BeforeSetParameterEvent evt) {
74
                if (EVENT_LOG.isDebugEnabled()) {
1✔
75
                        EVENT_LOG.debug("Before Set Parameter - Parameter:{}", evt.getParameter());
1✔
76
                }
77
        }
1✔
78

79
        void afterGetOutParameter(final AfterGetOutParameterEvent evt) {
80
                if (EVENT_LOG.isDebugEnabled()) {
×
81
                        EVENT_LOG.debug("After Get OutParameter - key:{}, value:{}. parameterIndex:{}",
×
82
                                        evt.getKey(), evt.getValue(), evt.getParameterIndex());
×
83
                }
UNCOV
84
        }
×
85

86
        void afterSqlQuery(final AfterSqlQueryEvent evt) {
87
                if (EVENT_LOG.isDebugEnabled()) {
1✔
88
                        EVENT_LOG.debug("Execute Query - sqlName:{} executed.", evt.getExecutionContext().getSqlName());
1✔
89
                        EVENT_LOG.trace("Execute Query sql:{}", evt.getPreparedStatement());
1✔
90
                }
91
        }
1✔
92

93
        void afterSqlUpdate(final AfterSqlUpdateEvent evt) {
94
                if (EVENT_LOG.isDebugEnabled()) {
1✔
95
                        EVENT_LOG.debug("Execute Update - sqlName:{} executed. Count:{} items.",
1✔
96
                                        evt.getExecutionContext().getSqlName(), evt.getCount());
1✔
97
                }
98
        }
1✔
99

100
        void afterSqlBatch(final AfterSqlBatchEvent evt) {
101
                if (EVENT_LOG.isDebugEnabled()) {
1✔
102
                        var counts = evt.getCounts();
1✔
103
                        try {
104
                                counts = new int[] { evt.getPreparedStatement().getUpdateCount() };
1✔
UNCOV
105
                        } catch (SQLException ex) {
×
UNCOV
106
                                EVENT_LOG.error(ex.getMessage(), ex);
×
107
                        }
1✔
108

109
                        var builder = new StringBuilder();
1✔
110
                        for (int val : counts) {
1✔
111
                                builder.append(val).append(", ");
1✔
112
                        }
113
                        EVENT_LOG.debug("Execute Update - sqlName:{} executed. Results:{}",
1✔
114
                                        evt.getExecutionContext().getSqlName(), counts);
1✔
115
                }
116
        }
1✔
117
}
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

© 2026 Coveralls, Inc