You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2019/03/26 11:22:22 UTC

[GitHub] [incubator-shardingsphere] mydingwei opened a new issue #2105: `java.io.NotSerializableException` occurred when setting parameters into PreparedStatement

mydingwei opened a new issue #2105: `java.io.NotSerializableException` occurred when setting parameters into PreparedStatement
URL: https://github.com/apache/incubator-shardingsphere/issues/2105
 
 
   + table_demo (id int primary key, column_a int, column_b longtext)
   
   + mybatis dynamic sql like this: 
   ```
   insert into table_demo (id, column_a, column_b) values ((#{id,jdbcType=VARCHAR}, #{columnA,jdbcType=INTEGER}, #{columnB,jdbcType=LONGVARCHAR})
   ```
   
   If jdbcType of columnB is specified as `org.apache.ibatis.type.JdbcType.LONGVARCHAR`, this parameter will be handled in `SimpleExecutor.preparedStatement(..)` method, and then `org.apache.ibatis.type.ClobTypeHandler.setNonNullParameter(..)` method will be called. 
   
   Type of column_b will be packaged in StringReader, thus the `parameters` property's type in ShardingPreparedStatement will be set to StringReader. 
   
   Subsequently, `replaySetParameter(final PreparedStatement preparedStatement, final List<Object> parameters)` will be called in `ShardingPreparedStatement's route()` method. 
   
   When the code goes to `each.invoke(preparedStatement);`, `com.mysql.jdbc.PreparedStatement.setObject(int parameterIndex, Object parameterObj)` will be invoked, and `StringReader` cannot be identified by `PreparedStatement`, then `setSerializableObject` will be called, but `StringReader` doesnot implement `Serializable`, so `java.io.NotSerializableException` occur.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services