1515 */
1616package org .apache .ibatis .logging .jdbc ;
1717
18+ import org .apache .ibatis .builder .SqlSourceBuilder ;
19+ import org .apache .ibatis .logging .Log ;
20+ import org .apache .ibatis .reflection .ArrayUtil ;
21+
1822import java .lang .reflect .Method ;
1923import java .sql .Array ;
2024import java .sql .PreparedStatement ;
2125import 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 .*;
2927import java .util .stream .Collectors ;
3028
31- import org .apache .ibatis .builder .SqlSourceBuilder ;
32- import org .apache .ibatis .logging .Log ;
33- import org .apache .ibatis .reflection .ArrayUtil ;
34-
3529/**
3630 * Base class for proxies to do logging.
3731 *
@@ -75,9 +69,16 @@ public BaseJdbcLogger(Log log, int queryStack) {
7569 }
7670
7771 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 );
7980 columnNames .add (key );
80- columnValues .add (value );
81+ columnValues .add (tempValue );
8182 }
8283
8384 protected Object getColumn (Object key ) {
@@ -90,7 +91,10 @@ protected String getParameterValueString() {
9091 if (value == null ) {
9192 typeList .add ("null" );
9293 } 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+ );
9498 }
9599 }
96100 final String parameters = typeList .toString ();
@@ -104,6 +108,8 @@ protected String objectValueString(Object value) {
104108 } catch (SQLException e ) {
105109 // Intentialy fall through to return value.toString()
106110 }
111+ }else if (value .getClass ().isArray ()){
112+ return ArrayUtil .toString (value );
107113 }
108114 return value .toString ();
109115 }
0 commit comments