java中流转化为Object可序列化

一.PO实体类

public class buisPO{

      /**
        * 业务数据
       */ 
       private Bolb buisData;

       public Blob getBusiData() {
		return this.busiData;
       }
       public void setBusiData(Blob busiData) {
		this.busiData = busiData;
} }

二.从数据库获取此Blob对象

busiPO busiPo = busiDAO.findUniqueWithProperty(paramMap);
InputStream is = null;
    try {
       if (istApprBusiDataPo != null) {
               is = busiPo.getBusiData().getBinaryStream(); //从Blob(大对象)获取二进制流
        } else {
                    return null;
        }
     } catch (SQLException e) {
            logger.error("获取业务数据出错", e);
            throw new ShineException(e);
    }
    return (Serializable) SerializationUtils.deserialize(is);   //利用SerializationUtils该类为序列化工具类,把输入流反序列号
    //SerializationUtils该类为序列化工具类,也是lang包下的工具,主要用于序列化操作,同时提供对象克隆接口

三.把序列化转换为Object

return (Object)tempBusiDataEnti.queryBusiDataByInstanceId(instanceId);

 

  

posted @ 2016-04-23 23:01  独具匠心  阅读(1789)  评论(0编辑  收藏  举报