Q:

Jackson, how to ignore some values

I'd like to exclude all properties with values less than zero. Does Jackson have some ready to use solutions or I should create CustomSerializerFactory and BeanPropertyWriter?

A:

You can do this by using a filter - it's a little verbose but it does the job. 
First - you need to specify the filter on your entity: 
@JsonFilter("myFilter")
public class MyDtoWithFilter { ...}

Then, you need to specify your custom filter, which will look at the values: 
PropertyFilter theFilter = new SimpleBeanPropertyFilter() {
  @Override
  public void serializeAsField(Object pojo, JsonGenerator jgen, SerializerProvider provider, PropertyWriter writer) throws Exception {
    if (include(writer)) {
      if (writer.getName().equals("intValue")) {
        int intValue = ((MyDtoWithFilter) pojo).getIntValue();
        if (intValue < 0) {
          writer.serializeAsField(pojo, jgen, provider);
        }
      } else {
        writer.serializeAsField(pojo, jgen, provider);
      }
    } else if (!jgen.canOmitFields()) { // since 2.3
      writer.serializeAsOmittedField(pojo, jgen, provider);
    }
  }

  @Override
  protected boolean include(BeanPropertyWriter writer) {
    return true;
  }
  @Override
  protected boolean include(PropertyWriter writer) {
    return true;
  }
};

This is done for a field called intValue but you can do the same for all your fields that need to be positive in a similar way. 
Finally, not you can marshall an object and test that it works: 
FilterProvider filters = new SimpleFilterProvider().addFilter("myFilter", theFilter);
MyDtoWithFilter dtoObject = new MyDtoWithFilter();
dtoObject.setIntValue(12);

ObjectMapper mapper = new ObjectMapper();
String dtoAsString = mapper.writer(filters).writeValueAsString(dtoObject);

Hope this helps. 

