Annotation Interface Field


Annotation to define custom metadata for document fields.
Author:
Oliver Gierke, Christoph Strobl, Divya Srivastava
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Enumeration of write strategies to define when a property is included for write conversion.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The key to be used to store the field inside the document.
    The used type has impact on how a given name() is treated if it contains dot (.) characters.
    int
    The order in which various fields shall be stored.
    The actual desired target type the field should be stored as.
    The key to be used to store the field inside the document.
    Write rules when to include a property value upon conversion.
  • Element Details

    • value

      @AliasFor("name") String value
      The key to be used to store the field inside the document. Alias for name().
      Returns:
      an empty String by default.
      See Also:
      Default:
      ""
    • name

      @AliasFor("value") String name
      The key to be used to store the field inside the document. Alias for value(). The name may contain MongoDB special characters like dot (.). In this case the name is by default treated as a path. To preserve dots within the name set the nameType() attribute to FieldName.Type.KEY.
      Returns:
      an empty String by default.
      Since:
      2.2
      Default:
      ""
    • nameType

      FieldName.Type nameType
      The used type has impact on how a given name() is treated if it contains dot (.) characters.
      Returns:
      FieldName.Type.PATH by default.
      Since:
      4.2
      Default:
      PATH
    • order

      int order
      The order in which various fields shall be stored. Has to be a positive integer.
      Returns:
      the order the field shall have in the document or -1 if undefined.
      Default:
      2147483647
    • targetType

      FieldType targetType
      The actual desired target type the field should be stored as.
      Returns:
      FieldType.IMPLICIT by default.
      Since:
      2.2
      Default:
      IMPLICIT
    • write

      Write rules when to include a property value upon conversion. If set to Field.Write.NON_NULL (default) null values are not written to the target Document. Setting the value to Field.Write.ALWAYS explicitly adds an entry for the given field holding null as a value 'fieldName' : null .
      NOTE: Setting the value to Field.Write.ALWAYS may lead to increased document size.
      Returns:
      Field.Write.NON_NULL by default.
      Since:
      3.3
      Default:
      NON_NULL