Commit 329a531c by 吴佳

多表readset查询CLOB类型报错修复

parent b370961e
......@@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.Reader;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
......@@ -307,7 +308,24 @@ public class MyBatisDaoSession extends AbstractDaoSession implements IDaoSession
if (field.getType().getName().equals("java.lang.Integer") && fieldVal instanceof BigDecimal) {
method.invoke(module, ((BigDecimal) fieldVal).intValue());
} else {
method.invoke(module, fieldVal);
//如果是CLOB类型的数据,将数据转换为String
if(fieldVal instanceof oracle.sql.CLOB){
try(Reader rsReader = ((oracle.sql.CLOB)fieldVal).getCharacterStream()){
char [] chs = new char[2048];
StringBuffer sb = new StringBuffer();
int i =0;
while((i=rsReader.read(chs))!=-1) {
sb.append(chs,0,i);
}
System.out.println("clob to string >>"+sb.toString());
method.invoke(module, sb.toString());
}catch (Exception e) {
log.error("执行方法{}时CLOB类型数据转String异常",methodName);
}
}else {
method.invoke(module, fieldVal);
}
}
}
} catch (InvocationTargetException e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment