public static byte[] serialize(Object obj,DataHandler dataHandler){
  try {
    JavaObjectSerializer handlerSerializer=null;
    if (dataHandler != null) {
      handlerSerializer=dataHandler.getJavaObjectSerializer();
    }
    if (handlerSerializer != null) {
      return handlerSerializer.serialize(obj);
    }
    if (serializer != null) {
      return serializer.serialize(obj);
    }
    ByteArrayOutputStream out=new ByteArrayOutputStream();
    ObjectOutputStream os=new ObjectOutputStream(out);
    os.writeObject(obj);
    return out.toByteArray();
  }
 catch (  Throwable e) {
    throw DbException.get(ErrorCode.SERIALIZATION_FAILED_1,e,e.toString());
  }
}

public static byte [ ] serialize ( Object obj , DataHandler dataHandler ) { try { JavaObjectSerializer handlerSerializer = null ; if ( dataHandler != null ) { handlerSerializer = dataHandler . getJavaObjectSerializer ( ) ; } if ( handlerSerializer != null ) { return handlerSerializer . serialize ( obj ) ; } if ( serializer != null ) { return serializer . serialize ( obj ) ; } ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; ObjectOutputStream os = new ObjectOutputStream ( out ) ; os . writeObject ( obj ) ; return out . toByteArray ( ) ; } catch ( Throwable e ) { throw DbException . get ( ErrorCode . SERIALIZATION_FAILED_1 , e , e . toString ( ) ) ; } }
serialize the object to a byte array , using the serializer specified by the connection info if set , or the default serializer .
