8.12.6 @Column
- Organization of this subsection
(1) Description
This annotation specifies the mapping between the persistence field or persistence property, and the columns of the database.
Even when @Column is not specified explicitly in the persistence property or persistence field, the persistence property or persistence field is handled as if @Column were specified. In such a case, the default values will be applied in each element value of @Column.
The applicable targets are method and field.
(2) Element
The following table lists the elements of @Column:
Element name |
Optional/Required |
Element description |
---|---|---|
Optional |
This element specifies the column name. |
|
unique |
Optional |
This element specifies whether or not the property is a unique key. Note that Cosminexus JPA provider does not support this attribute. |
nullable |
Optional |
This element specifies whether or not a null value can be specified in the database column. Note that Cosminexus JPA provider does not support this attribute. |
Optional |
This element specifies whether or not to include the column specified by @Column in the INSERT statement of the SQL. |
|
Optional |
This element specifies whether or not to include the column specified by @Column in the UPDATE statement of the SQL. |
|
columnDefinition |
Optional |
This element is used to describe the constraints added to the column in the DDL, when the CREATE statement is output. Note that Cosminexus JPA provider does not support this attribute. |
Optional |
This element specifies the table name that includes the column. |
|
length |
Optional |
This element specifies the length of a column. Note that Cosminexus JPA provider does not support this attribute. |
precision |
Optional |
This element specifies the accuracy of a column. This element is specified when the column is numeric type. Note that Cosminexus JPA provider does not support this attribute. |
scale |
Optional |
This element specifies the scale of a column. This element is specified when the column is numeric type. Note that Cosminexus JPA provider does not support this attribute. |
The details of attributes that are supported with Cosminexus JPA provider are as follows:
(a) name element
- Type
-
String
- Description
-
This element specifies the column name.
The column name that can be specified depends on the database specifications.
- Default value
-
Property name or field name in which this annotation is specified
(b) insertable element
- Type
-
boolean
- Description
-
This element specifies whether or not to include the column specified by @Column in the INSERT statement of the SQL. You can specify either true or false.
These values imply the following meaning:
true: The column specified by @Column is included in the INSERT statement of the SQL.
false: The column specified by @Column is not included in the INSERT statement of the SQL.
- Default value
-
true
(c) updatable element
- Type
-
boolean
- Description
-
This element specifies whether or not to include the column specified by @Column in the UPDATE statement of the SQL. You can specify either true or false.
These values imply the following meaning:
true: The column specified by @Column is included in the UPDATE statement of the SQL.
false: The column specified by @Column is not included in the UPDATE statement of the SQL.
- Default value
-
true
(d) table element
- Type
-
String
- Description
-
This element specifies the table name that includes the column.
The table name that can be specified depends on the database specifications.
- Default value
-
Primary table name