15
15
*/
16
16
package org .apache .ibatis .logging .jdbc ;
17
17
18
+ import org .apache .ibatis .builder .SqlSourceBuilder ;
19
+ import org .apache .ibatis .logging .Log ;
20
+ import org .apache .ibatis .reflection .ArrayUtil ;
21
+
18
22
import java .lang .reflect .Method ;
19
23
import java .sql .Array ;
20
24
import java .sql .PreparedStatement ;
21
25
import java .sql .SQLException ;
22
- import java .util .ArrayList ;
23
- import java .util .Arrays ;
24
- import java .util .HashMap ;
25
- import java .util .HashSet ;
26
- import java .util .List ;
27
- import java .util .Map ;
28
- import java .util .Set ;
26
+ import java .util .*;
29
27
import java .util .stream .Collectors ;
30
28
31
- import org .apache .ibatis .builder .SqlSourceBuilder ;
32
- import org .apache .ibatis .logging .Log ;
33
- import org .apache .ibatis .reflection .ArrayUtil ;
34
-
35
29
/**
36
30
* Base class for proxies to do logging.
37
31
*
@@ -43,10 +37,10 @@ public abstract class BaseJdbcLogger {
43
37
protected static final Set <String > SET_METHODS ;
44
38
protected static final Set <String > EXECUTE_METHODS = new HashSet <>();
45
39
46
- private final Map <Object , Object > columnMap = new HashMap <>();
40
+ private final Map <Object , String > columnMap = new HashMap <>();
47
41
48
42
private final List <Object > columnNames = new ArrayList <>();
49
- private final List <Object > columnValues = new ArrayList <>();
43
+ private final List <String > columnValues = new ArrayList <>();
50
44
51
45
protected final Log statementLog ;
52
46
protected final int queryStack ;
@@ -75,9 +69,18 @@ public BaseJdbcLogger(Log log, int queryStack) {
75
69
}
76
70
77
71
protected void setColumn (Object key , Object value ) {
78
- columnMap .put (key , value );
72
+ String valueString = null ;
73
+ if (value !=null ){
74
+ valueString = objectValueString (value ) +
75
+ "(" + value .getClass ().getSimpleName ()+")" ;
76
+ } else {
77
+ valueString = "null" ;
78
+ }
79
+
80
+
81
+ columnMap .put (key , valueString );
79
82
columnNames .add (key );
80
- columnValues .add (value );
83
+ columnValues .add (valueString );
81
84
}
82
85
83
86
protected Object getColumn (Object key ) {
@@ -87,11 +90,7 @@ protected Object getColumn(Object key) {
87
90
protected String getParameterValueString () {
88
91
List <Object > typeList = new ArrayList <>(columnValues .size ());
89
92
for (Object value : columnValues ) {
90
- if (value == null ) {
91
- typeList .add ("null" );
92
- } else {
93
- typeList .add (objectValueString (value ) + "(" + value .getClass ().getSimpleName () + ")" );
94
- }
93
+ typeList .add (value );
95
94
}
96
95
final String parameters = typeList .toString ();
97
96
return parameters .substring (1 , parameters .length () - 1 );
0 commit comments