jakarta.persistence.Column
- Implemented Interfaces:
Annotation
- Target:
- Method, Field
If no Column annotation is explicitly specified, the default values apply.
Example 1:
@Column(name = "DESC", nullable = false, length = 512) public String getDescription() { return description; }
Example 2:
@Column(name = "DESC", columnDefinition = "CLOB NOT NULL", table = "EMP_DETAIL") @Lob public String getDescription() { return description; }
Example 3:
@Column(name = "ORDER_COST", updatable = false, precision = 12, scale = 2) public BigDecimal getCost() { return cost; }
Portable applications which make use of schema generation should explicitly specify the precision and scale of columns of type numeric or decimal.
- Since:
- Jakarta Persistence (JPA) 1.0
Annotation Elements
String name- Default:
- ""
- Since:
- Jakarta Persistence (JPA) 1.0
boolean uniqueUniqueConstraint annotation at the table level and is useful for when the unique key constraint corresponds to only a single column. This constraint applies in addition to any constraint entailed by the primary key mapping and to constraints specified at the table level.- Default:
- false
- Since:
- Jakarta Persistence (JPA) 1.0
boolean nullable- Default:
- true
- Since:
- Jakarta Persistence (JPA) 1.0
boolean insertable- Default:
- true
- Since:
- Jakarta Persistence (JPA) 1.0
boolean updatable- Default:
- true
- Since:
- Jakarta Persistence (JPA) 1.0
String columnDefinitionDefaults to the generated SQL to create a column of the inferred type.
The specified DDL must be written in the native SQL dialect of the target database, and is not portable across databases.
- Default:
- ""
- Since:
- Jakarta Persistence (JPA) 1.0
String optionscolumnDefinition. The specified DDL must be written in the native SQL dialect of the target database, and is not portable across databases.
- Default:
- ""
- Since:
- Jakarta Persistence (JPA) 3.2
String table- Default:
- ""
- Since:
- Jakarta Persistence (JPA) 1.0
int length Applies only to columns whose type is parameterized by length, for example, varchar or varbinary types.
- Default:
- 255
- Since:
- Jakarta Persistence (JPA) 1.0
int precisionApplies only to columns of exact numeric type.
The default value 0 indicates that a provider-determined precision should be inferred.
- Default:
- 0
- Since:
- Jakarta Persistence (JPA) 1.0
int scaleApplies only to columns of exact numeric type.
The default value 0 indicates that a provider-determined scale should be inferred.
- Default:
- 0
- Since:
- Jakarta Persistence (JPA) 1.0
int secondPrecisionApplies only to columns of time or timestamp type.
The default value -1 indicates that fractional seconds should not be stored in a time column, or that the maximum number of digits supported by the database and JDBC driver should be stored in a timestamp column.
- Default:
- -1
- Since:
- Jakarta Persistence (JPA) 3.2
- Default:
- {}
- Since:
- Jakarta Persistence (JPA) 3.2
String comment- Default:
- ""
- Since:
- Jakarta Persistence (JPA) 3.2
Additional JDK methods inherited from java.lang.annotation.Annotation
annotationType(), equals(Object), hashCode(), toString()