mybatis读取longraw失败getBLOB not implemented for class oracle.jdbc.driver.T4CLongRawAccessor

是mybatis自身的问题,可通过自定义转换器解决,新建LongVarBinaryHandler类

import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.TypeHandler;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class LongVarBinaryHandler implements TypeHandler {

    public LongVarBinaryHandler(){

    }

    @Override
    public void setParameter(PreparedStatement preparedStatement, int i, byte[] bytes, JdbcType jdbcType) throws SQLException {

    }

    @Override
    public byte[] getResult(ResultSet resultSet, String s) throws SQLException {
        byte[] result = resultSet.getBytes(s);
        return result;
    }

    @Override
    public byte[] getResult(ResultSet resultSet, int i) throws SQLException {
        byte[] result = resultSet.getBytes(i);
        return result;
    }

    @Override
    public byte[] getResult(CallableStatement callableStatement, int i) throws SQLException {
        return new byte[0];
    }

}

在mapper文件需要转换的字段上添加typehandler,需要填写完整路径


WechatIMG2.png

你可能感兴趣的:(mybatis读取longraw失败getBLOB not implemented for class oracle.jdbc.driver.T4CLongRawAccessor)