Skip to content

Commit

Permalink
docs: enhance documentation to Column annotation
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Santana <otaviopolianasantana@gmail.com>
  • Loading branch information
otaviojava committed Feb 19, 2024
1 parent e438a93 commit e9b6519
Showing 1 changed file with 30 additions and 13 deletions.
43 changes: 30 additions & 13 deletions api/nosql-core/src/main/java/jakarta/nosql/Column.java
Expand Up @@ -22,45 +22,62 @@
import java.lang.annotation.Target;

/**
* Specify the mapped column for a persistent property or field.
* Specifies the column mapped by the annotated persistent property or field.
* <p>
* If no {@code Column} annotation is explicitly specified, the field will be ignored by Jakarta NoSQL.
* </p>
*
* @see Entity
* <p>
* Example 1:
* <pre>{@code
* @Column(name = "DESC")
* private String description;
* }</pre>
* </p>
*
* @since 1.0.0
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.PARAMETER})
@Target({ElementType.FIELD})
public @interface Column {
/**
* (Optional) The name of the column. Defaults to the property or field name.
*
* <p>
* The sample below shows the {@code Person} entity where the mapped fields with {@code @Column} will be going be mapped to columns with their respective field name:
* For example, in the {@code Person} entity class below, the mapped fields with {@code @Column}
* will be mapped to columns with their respective field name:
* </p>
*
* <pre>{@code
* @Entity
* public class Person {
*
* @Column
* private String name;
*
* }
* }</pre>
*
* <p>
* If any name customization is needed, it just set the single attribute of the annotation to specify the desired name.
* In the sample below the Person name field will be mapped to the "personName" column:
* If any name customization is needed, set the value of this attribute to specify the desired name.
* For instance, in the example below, the {@code name} field of the {@code Person} class will be mapped
* to the "personName" column:
* </p>
* <pre>{@code
* @Entity
* public class Person {
*
* @Column("personName")
* private String name;
*
* }
* }</pre>
*
* @return the column name
*/
String value() default "";

/**
* (Optional) Defines the name of the user-defined type (UDT) used by the NoSQL database for this field.
* <p>
* 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.
* </p>
*
* @return the user-defined type (UDT) name
*/
String udt() default "";
}

0 comments on commit e9b6519

Please sign in to comment.