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
*
@@ -75,9 +69,16 @@ 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
+ Object tempValue = value ;
73
+ if (tempValue !=null && tempValue instanceof Array ){
74
+ try {
75
+ tempValue = ((Array )value ).getArray ();
76
+ } catch (SQLException e ) {
77
+ }
78
+ }
79
+ columnMap .put (key , tempValue );
79
80
columnNames .add (key );
80
- columnValues .add (value );
81
+ columnValues .add (tempValue );
81
82
}
82
83
83
84
protected Object getColumn (Object key ) {
@@ -90,7 +91,10 @@ protected String getParameterValueString() {
90
91
if (value == null ) {
91
92
typeList .add ("null" );
92
93
} else {
93
- typeList .add (objectValueString (value ) + "(" + value .getClass ().getSimpleName () + ")" );
94
+ typeList .add (objectValueString (value ) +
95
+ "(" + (value .getClass ().isArray () ?
96
+ Array .class .getSimpleName ():value .getClass ().getSimpleName ()) + ")"
97
+ );
94
98
}
95
99
}
96
100
final String parameters = typeList .toString ();
@@ -104,6 +108,8 @@ protected String objectValueString(Object value) {
104
108
} catch (SQLException e ) {
105
109
// Intentialy fall through to return value.toString()
106
110
}
111
+ }else if (value .getClass ().isArray ()){
112
+ return ArrayUtil .toString (value );
107
113
}
108
114
return value .toString ();
109
115
}
0 commit comments