code: public void write(ObjectWriter out, PersistedValueData vd) throws IOException
     {
        out.writeInt(SerializationConstants.PERSISTED_VALUE_DATA);
        out.writeInt(vd.getOrderNumber());
  
        boolean isByteArray = vd.isByteArray();
        out.writeBoolean(isByteArray);
  
        if (isByteArray)
        {
           byte[] data = vd.getAsByteArray();
           out.writeInt(data.length);
           out.write(data);
        }
        else
        {
           // write file content
           FilePersistedValueData streamed = (FilePersistedValueData)vd;
  
           InputStream in = null;
  
           if (streamed.getFile() == null && vd instanceof StreamPersistedValueData)
           {
              if (((StreamPersistedValueData)vd).getTempFile() != null)
              {
                 in = PrivilegedFileHelper.fileInputStream(((StreamPersistedValueData)vd).getTempFile());
              }
           }
           else
           {
              in = streamed.getAsStream();
           }
  
           if (streamed.getFile() instanceof SerializationSpoolFile)
           {
              SerializationSpoolFile ssf = (SerializationSpoolFile)streamed.getFile();
              out.writeString(ssf.getId());
              out.writeLong(0);
           }
           else
           {
              // write property id - used for reread data optimization
              String id = IdGenerator.generate();
              out.writeString(id);
  
              if (in == null)
              {
                 // Deleted state usecase
                 out.writeLong(SerializationConstants.NULL_FILE);
              }
              else
              {
                 out.writeLong(vd.getLength());
                 try
                 {
                    byte[] buf = new byte[SerializationConstants.INTERNAL_BUFFER_SIZE];
                    int l = 0;
                    while ((l = in.read(buf)) >= 0)
                    {
                       out.write(buf, 0, l);
                    }
                 }
                 finally
                 {
                    in.close();
                 }
              }
           }
        }
     }
docs: Write to stream all necessary object data.
  
  @param out
  SerializationOutputStream.
  @throws IOException
  If an I/O error has occurred.