Annotation Interface Column


@Retention(RUNTIME) @Target(FIELD) public @interface Column
Annotation for customizing field-to-column mapping.

By default, field names are converted to snake_case. Use this annotation to specify a custom column name or mark a field as transient.

Example:

@Entity
public class UserData {
    private Long id;

    @Column(name = "discord_user_id")
    private Long userId;

    @Column(ignore = true)
    private transient String cachedValue;  // Not persisted
}

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Whether this field should be ignored during persistence.
    Custom column name.
  • Element Details

    • name

      String name
      Custom column name.

      If empty, the field name is converted to snake_case.

      Returns:
      the column name
      Default:
      ""
    • ignore

      boolean ignore
      Whether this field should be ignored during persistence.
      Returns:
      true to ignore this field
      Default:
      false