-
@Target({METHOD,FIELD}) @Retention(RUNTIME) public @interface Column
Specifies the mapped column for a persistent property or field. If noColumn
annotation is 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; }
- 从以下版本开始:
- Java Persistence 1.0
-
-
可选元素概要
可选元素 修饰符和类型 可选元素 说明 String
comment
(Optional) The comment of the column.String
example
for OpenAPI Specification 3boolean
insertable
(Optional) Whether the column is included in SQL INSERT statements generated by the persistence provider.int
length
(Optional) The column length.String
name
(Optional) The name of the column.boolean
nullable
(Optional) Whether the database column is required.int
precision
(Optional) The precision for a decimal (exact numeric) column.int
scale
(Optional) The scale for a decimal (exact numeric) column.boolean
unique
(Optional) Whether the column is a unique key.boolean
updatable
(Optional) Whether the column is included in SQL UPDATE statements generated by the persistence provider.
-
-
-
元素详细资料
-
name
String name
(Optional) The name of the column. Defaults to the property or field name.- 返回:
- String
- 默认值:
- ""
-
-
-
comment
String comment
(Optional) The comment of the column.- 返回:
- String
- 默认值:
- ""
-
-
-
unique
boolean unique
(Optional) Whether the column is a unique key. This is a shortcut for theUniqueConstraint
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 primary key mapping and to constraints specified at the table level.- 返回:
- boolean
- 默认值:
- false
-
-
-
example
String example
for OpenAPI Specification 3- 返回:
- String
- 默认值:
- ""
-
-
-
length
int length
(Optional) The column length. (Applies only if a string-valued column is used.) if type==String and length == 65535 then sqltype is TEXT
if type==String and length <= 16777215 then sqltype is MEDIUMTEXT
if type==String and length > 16777215 then sqltype is LONGTEXT
if type==byte[] and length <= 65535 then sqltype is BLOB
if type==byte[] and length <= 16777215 then sqltype is MEDIUMBLOB
if type==byte[] and length > 16777215 then sqltype is LONGBLOB- 返回:
- int
- 默认值:
- 255
-
-