Spring+Mybatis类型转换的问题,oracle数据库中有一个clob类型,怎样在查询以后转换为String类型?

我在mapper文件里返回的不是实体类,而是一个Map类型,所以无法自动转换,我在配置文件中配置类型转换没有作用:
<typeHandlers>
<typeHandler javaType="String" jdbcType="CLOB" handler="org.apache.ibatis.type.ClobTypeHandler"/>
</typeHandlers>
有大神们能指点一下吗

首先你的思路就错的,不可能转换成string

  1. 把大对象读进byte[]

     

public byte[] function(Connection connection,所需参数) throws EMPException{
  
  PreparedStatement ps = null;
  ResultSet rs = null;
  byte[] data = null;
  try {
   .....省略
   while (rs.next()) {
    oracle.sql.CLOB  clob= (oracle.sql.CLOB) rs.getClob("大对象的字段名");
    InputStream inStream =clob.getBinaryStream();
    long nLen = clob.length();
                int nSize = (int) nLen;
                data = new byte[nSize];
                inStream.read(data);
                inStream.close();
                connection.commit();

   }
  } catch (SQLException e) {
   EMPLog.log(this.getClass().getName(), EMPLog.INFO, 0, e.toString());
 宽乱 } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } finally {
   try {
    if (rs != null) {
     纤裤rs.close();
     rs = null;
    }
    if (ps != null) {
     ps.close();
     ps = null;
    }
   } catch (SQLException e) {
    EMPLog.log(this.getClass().getName(), EMPLog.INFO, 0, e
      .toString());
   }
  }
  return data;
 }

2.直接在页面上将对象读到页面上

<form action="">
<%
    
    response.setContentType("image/jpg");
    response.setHeader("Content-Transfer-Encoding","base64");
    ServletOutputStream toClient = response.getOutputStream();
            out.clear();
            out = pageContext.pushBody();
            ByteArrayInputStream in = new ByteArrayInputStream(data); 
            int len;
            byte[] buf = new byte[1024];
            while ((len = in.read(buf, 0, 1024)) != -1) {
             toClient.write(buf, 0, len);
            }
            toClient.flush();
            toClient.close();
     毁巧简   %>
        </form>


默认Clob是会转成byte[] ,你可以在用的时候转成String