Annotation Interface Column


@Retention(RUNTIME) @Target(FIELD) public @interface Column
Specifies the mapping of an entity attribute to a database column.

This annotation is used to map a Java class field to a database column. It allows customization of various column properties such as name, uniqueness, nullability, and column definition.

Example usage:


   @Entity
   public class Entity {
       @Column(name = "first_name", unique = true, nullable = false, columnDefinition = "text")
       private String firstName;
       // Other fields and methods
   }
 
Since:
1.0
Author:
Blyzhnytsia Team
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    (Optional) The SQL fragment that is used when generating the DDL for the column.
    (Optional) The name of the column in the database table.
    boolean
    (Optional) Whether the database column is nullable.
    boolean
    (Optional) Whether the column is a unique key.
  • Element Details

    • name

      String name
      (Optional) The name of the column in the database table.
      Returns:
      The name of the column.
      Default:
      ""
    • unique

      boolean unique
      (Optional) Whether the column is a unique key.
      Returns:
      Whether the column is a unique key.
      Default:
      false
    • nullable

      boolean nullable
      (Optional) Whether the database column is nullable.
      Returns:
      Whether the column allows NULL values.
      Default:
      true
    • columnDefinition

      String columnDefinition
      (Optional) The SQL fragment that is used when generating the DDL for the column.
      Returns:
      The custom SQL fragment.
      Default:
      ""