Annotation Interface Column


Specifies the mapped column for a persistent field.

If no Column annotation is specified, the default values apply.

This is a meta-annotation: it can be applied to other annotations; if you use these annotations, YOJ will correctly apply the @Column annotation. This allows you to define reusable column customizations. See e.g. @ObjectColumn.

Usage Example:

 // DB column will have name 'DESC' and DB-specific type 'UTF8'
 @Column(name = "DESC", dbType = DbType.UTF8)
 String description;

 // Subobject's serialized representation will be written to a single BIG_SUBOBJ column
 @Column(name = "BIG_SUBOBJ", flatten = false)
 BigSubobject subobj1;

 // The subobject will be recursively "flattened" into DB columns of primitive types (string,
 // number, boolean). Each column will have the "BIG_SUBOBJ_FLAT" prefix.
 // (flatten=true is default databinding behavior and is shown here for clarity.)
 @Column(name = "BIG_SUBOBJ_FLAT", flatten = true)
 BigSubobject subobj2;
 
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Specifies custom conversion logic for this column, if any.
    The type of the DB column.
    Defaults to automatically inferred from the field type.
    Qualifier for refining type representation of the DB column.
    Defaults to automatically inferred from the field type.
    boolean
    Determines whether the composite field will be: flattened into multiple primitive-typed DB columns (flatten=true), or represented as a single column holding the serialized representation of the field's value (flatten=false). Defaults to true (flatten composite fields).
    Changing this parameter for a non-composite field has no effect.
    The name of the DB column.
    Defaults to the field name.
  • Element Details

    • name

      String name
      The name of the DB column.
      Defaults to the field name.
      Default:
      ""
    • dbType

      DbType dbType
      The type of the DB column.
      Defaults to automatically inferred from the field type.
      Default:
      DEFAULT
    • dbTypeQualifier

      String dbTypeQualifier
      Qualifier for refining type representation of the DB column.
      Defaults to automatically inferred from the field type.
      Default:
      ""
    • flatten

      boolean flatten
      Determines whether the composite field will be:
      • flattened into multiple primitive-typed DB columns (flatten=true),
      • or represented as a single column holding the serialized representation of the field's value (flatten=false).
    • Defaults to true (flatten composite fields).
      Changing this parameter for a non-composite field has no effect.

      Tip: Use the @ObjectColumn annotation if you only need to override @Column.flatten to false.