anchor.diff:        }
         return data;
      }
  +
  +  public static byte[] writeBean( final iris.beans.AbstractBean bean, final int attributesMask, final boolean includeToDate )
  +    throws java.io.IOException
  +  {
  +    final java.io.ByteArrayOutputStream output = new java.io.ByteArrayOutputStream();
  +    final java.io.ObjectOutputStream objectOutputStream = new java.io.ObjectOutputStream( output );
  +    try
  +    {
  +      <% schema.object_types.reverse.select{|o|!o.abstract? && o.iris.generate? }.each do |object_type|
  +     name = object_type.name
  +     type = j_classname(object_type.java.fully_qualified_name)
  +  %>if( <%= type %>.class.isInstance( bean ) )
  +      {
  +        write<%= object_type.name %>To( (<%= type %>)bean, objectOutputStream, includeToDate, attributesMask );
  +      }
  +      else <% end %>
  +      {
  +        final String message = "Unable to validate bean: " + bean;
  +        throw new IllegalArgumentException( message );
  +      }
  +    }
  +    catch ( final RuntimeException e )
  +    {
  +      iris.util.debug.IDebug.error( "Failed to write bean: " + bean + " using mask " + attributesMask );
  +      throw e;
  +    }
  +    return output.toByteArray();
  +  }
   
   <% schema.object_types.select{|o|!o.abstract? && o.iris.generate? }.each do |object_type|
   %>
  
positive.code:       data.put( iris.persist.DatabasePeer.ID, primaryKey );
  
        final int attributesMask;
        if ( 0 != ( metadataMask & iris.beans.io.BeanCodec.MD_ATTR_MASK ) )
        {
           attributesMask = input.readInt();
        }
        else
        {
          attributesMask = SERVER_TO_SERVER_ATTR_MASK_FOR_TYPE_CODE[typeCode - 1];
        }
        if ( 0 != ( metadataMask & iris.beans.io.BeanCodec.MD_TO_AND_FROM_DATES ) )
        {
           final long to = input.readLong();
           if ( 0 != to )
  
negative.code:     return -1;
    }
  
    public static java.util.Map<String, Object> readBean( final byte[] input, final boolean includeToDate )
      throws java.io.IOException, ClassNotFoundException
    {
      return readBean( new java.io.ObjectInputStream( new java.io.ByteArrayInputStream( input ) ), includeToDate );
    }
  
    private static java.util.Map<String, Object> readBean( final java.io.ObjectInput input, final boolean includeToDate )
       throws java.io.IOException, ClassNotFoundException
    {
        final java.util.Map<String, Object> data = new java.util.HashMap<String, Object>();
  