JAVA 深拷贝 oralce in 1000处理

public static String GetInClause(String field, List<String> valueList){
        if(valueList.size()==0){
            return " ";
        }

        Supplier<Stream<String>> idList = ()->valueList.stream().map((x) ->
        {
//            if (x.matches("[^a-zA-Z0-9-]")) //sql注入检查
//            {
//
//            }
            return String.format("'%1$s'", x);
        });
        var ret=" ";
        int pageSize = 900;
        int pageNum = 0;
        while (pageNum * pageSize < valueList.size())
        {
            List<String> list = idList.get().skip(pageSize*pageNum).limit(pageSize).collect(Collectors.toList());
            ret+= " or "+field+" in (" + String.join(",", list) + ") ";
            pageNum++;
        }
        return ret;

    }
    public static Object DeepCopy(Object src){
        try{
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            ObjectOutputStream out = new ObjectOutputStream(bos);
            out.writeObject(src);
            out.flush();
            out.close();

            ByteArrayInputStream bis = new  ByteArrayInputStream(bos.toByteArray());
            ObjectInputStream in = new ObjectInputStream(bis);
            Object toBean = in.readObject();
            in.close();
            return toBean;

        }catch (Exception e){
            throw new  FITVException("FI_TV_PUB_9999", e.getMessage());
        }
    }

除使用字节流外,还可以使用序列化

posted @ 2020-07-02 10:55  wolbo  阅读(185)  评论(0编辑  收藏  举报