Package jakarta.nosql

Annotation Interface Column


@Retention(RUNTIME) @Target({FIELD,PARAMETER}) public @interface Column
Declares that the annotated attribute is persistable and maps to a database column or key.

This annotation is required to make fields persistable in Jakarta NoSQL. Only attributes explicitly annotated with @Column will be included in persistence operations.

If the name attribute is omitted, the Java attribute name is used as the default mapping target.

Example with a custom column name:


 @Entity
 public class Product {

     @Column(name = "DESC")
     private String description;
 }
 

Note: @Column is also used in Projection classes for mapping query results. In that context, it is used for read-only access and supports mapping of nested or aliased fields.

Since:
1.0.0
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    (Optional) Defines the name of the user-defined type (UDT) used by the NoSQL database for this field.
    (Optional) The name of the column.
  • Element Details

    • value

      String value
      (Optional) The name of the column. Defaults to the property or field name.

      For example, in the Person entity class below, the mapped fields with @Column will be mapped to columns with their respective field name:

      
       @Entity
       public class Person {
           @Column
           private String name;
       }
       

      If any name customization is needed, set the value of this attribute to specify the desired name. For instance, in the example below, the name field of the Person class will be mapped to the "personName" column:

      
       @Entity
       public class Person {
           @Column("personName")
           private String name;
       }
       
      Returns:
      the column name
      Default:
      ""
    • udt

      String udt
      (Optional) Defines the name of the user-defined type (UDT) used by the NoSQL database for this field.

      If a NoSQL database supports UDTs, this attribute allows specifying the name of the UDT to be used for serializing this field. If the database does not support UDTs, this field will be skipped during serialization.

      Returns:
      the user-defined type (UDT) name
      Default:
      ""