当前位置: 首页>数据库>正文

Oracle数据库BLOB字段存JSONOBJECT或JSONARRY数据

//获取核注清单数据
InvtHeadType invtHeadType = new InvtHeadType();
invtHeadType = JSONObject.parseObject(JSON.toJSONString(ByteAryToObject(bisPreEntryInvtQuery.getInvtHeadType())),InvtHeadType.class);

List<InvtListType> invtListType = new ArrayList<>();
invtListType = JSONArray.parseArray(JSON.toJSONString(ByteAryToObject(bisPreEntryInvtQuery.getInvtListType())),InvtListType.class);

public static byte[] ObjectToByteAry(Object object) throws IOException{
    if(object == null){
        return null;
    }
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ObjectOutputStream sOut = null;
    sOut = new ObjectOutputStream(out);
    sOut.writeObject(object);
    sOut.flush();
    byte[] bytes = out.toByteArray();
    return bytes;
}
public static Object ByteAryToObject(byte[] bytes) throws IOException, ClassNotFoundException {
    if(bytes == null){
        return null;
    }
    ByteArrayInputStream in = new ByteArrayInputStream(bytes);
    ObjectInputStream sIn = null;
    Object obj = null;
    sIn = new ObjectInputStream(in);
    obj = sIn.readObject();
    return obj;
}


https://www.xamrdz.com/database/62x1960520.html

相关文章: