|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
javax.persistence Annotation Type Column
Implements:
Annotation
@Target(value={METHOD, FIELD})@Retention(value=RUNTIME)
用于指定持久属性或字段的映射列。如果没有指定 Column 注释,则应用默认值。
示例:
示例 1: @Column(name="DESC", nullable=false, length=512) public String getDescription() { return description; } 示例 2: @Column(name="DESC", columnDefinition="CLOB NOT NULL", table="EMP_DETAIL") @Lob public String getDescription() { return description; } 示例 3: @Column(name="ORDER_COST", updatable=false, precision=12, scale=2) public BigDecimal getCost() { return cost; }
since |
|
Is used to specify a mapped column for a persistent property or field. If no Column annotation is specified, the default values are applied.
Examples:
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; }
- Since:
- Java Persistence 1.0
Optional Element Summary | |
---|---|
String |
columnDefinition
(Optional) The SQL fragment that is used when generating the DDL for the column. |
boolean |
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 nullable. |
int |
precision
(Optional) The precision for a decimal (exact numeric) column. |
int |
scale
(Optional) The scale for a decimal (exact numeric) column. |
String |
table
(Optional) The name of the table that contains the column. |
boolean |
unique
(Optional) Whether the property is a unique key. |
boolean |
updatable
(Optional) Whether the column is included in SQL UPDATE statements generated by the persistence provider. |
abstract public String
name()
(可选)列名称。默认为属性或字段名称。
英文文档:
name
public abstract String name
- (Optional) The name of the column. Defaults to
the property or field name.
- Default:
- ""
abstract public boolean
unique()
(可选)属性是否为唯一键。这是表格级别的 UniqueConstraint 注释的快捷方式,在唯一的键约束只有一个字段时很有用。除了应用在表格级别指定的约束条件和主键映射引起的约束条件外,还应用此约束条件。
英文文档:
unique
public abstract boolean unique
- (Optional) Whether the property is a unique key. This is a
shortcut for the UniqueConstraint annotation at the table
level and is useful for when the unique key constraint is
only a single field. This constraint applies in addition
to any constraint entailed by primary key mapping and
to constraints specified at the table level.
- Default:
- false
abstract public boolean
nullable()
(可选)数据库列是否可以为 null。
英文文档:
nullable
public abstract boolean nullable
- (Optional) Whether the database column is nullable.
- Default:
- true
abstract public boolean
insertable()
(可选)持久性提供者生成的 SQL INSERT 语句中是否包含该列。
英文文档:
insertable
public abstract boolean insertable
- (Optional) Whether the column is included in SQL INSERT
statements generated by the persistence provider.
- Default:
- true
abstract public boolean
updatable()
(可选)持久性提供者生成的 SQL UPDATE 语句中是否包含该列。
英文文档:
updatable
public abstract boolean updatable
- (Optional) Whether the column is included in SQL UPDATE
statements generated by the persistence provider.
- Default:
- true
abstract public String
columnDefinition()
(可选)生成该列的 DDL 时使用的 SQL 句段。
默认为生成的 SQL,以创建推断类型的列。
columnDefinition
public abstract String columnDefinition
- (Optional) The SQL fragment that is used when
generating the DDL for the column.
Defaults to the generated SQL to create a column of the inferred type.
- Default:
- ""
abstract public String
table()
(可选)包含该列的表格名称。如果不存在,则假设该列位于主表格中。
英文文档:
table
public abstract String table
- (Optional) The name of the table that contains the column.
If absent the column is assumed to be in the primary table.
- Default:
- ""
abstract public int
length()
(可选)列长。(只在使用值为字符串的列时应用。)
英文文档:
length
public abstract int length
- (Optional) The column length. (Applies only if a
string-valued column is used.)
- Default:
- 255
abstract public int
precision()
(可选)十进制(精确数字)列的精度。(只在使用十进制列时应用。)如果在生成此列的 DDL 时使用,则开发人员必须设置此值。
英文文档:
precision
public abstract int precision
- (Optional) The precision for a decimal (exact numeric)
column. (Applies only if a decimal column is used.)
Value must be set by developer if used when generating
the DDL for the column.
- Default:
- 0
abstract public int
scale()
(可选)十进制(精确数字)列的小数位数。(只在使用十进制列时应用。)
英文文档:
scale
public abstract int scale
- (Optional) The scale for a decimal (exact numeric) column.
(Applies only if a decimal column is used.)
- Default:
- 0
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!