Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Basic Mappings/Column"
< EclipseLink | UserGuide | JPA | Basic JPA Development | Mapping | Basic Mappings
m |
|||
Line 7: | Line 7: | ||
= @Column = | = @Column = | ||
− | Use the Column annotation to specify a mapped column for a persistent property or field. | + | Use the Column annotation to specify a mapped column for a persistent property or field. If no Column annotation is specified, the default values, as shown in the table below, apply. |
.{{EclipseLink_Spec | .{{EclipseLink_Spec | ||
Line 82: | Line 82: | ||
− | <br> The following example shows how to use the <tt>@Column</tt> annotation to | + | <br> The following example shows how to use the <tt>@Column</tt> annotation, with values to override the defaults for <tt>updatable</tt>, <tt>precision</tt>, and <tt>scale</tt>. |
'''''Usage of the @Column Annotation''''' <source lang="java"> | '''''Usage of the @Column Annotation''''' <source lang="java"> |
Revision as of 14:18, 14 February 2011
EclipseLink | |
Website | |
Download | |
Community | |
Mailing List • Forums • IRC • mattermost | |
Issues | |
Open • Help Wanted • Bug Day | |
Contribute | |
Browse Source |
THIS PAGE IS IN PROGRESS...
@Column
Use the Column annotation to specify a mapped column for a persistent property or field. If no Column annotation is specified, the default values, as shown in the table below, apply.
.For more information, see Section 11.1.9 "Column Annotation" in the JPA Specification.
Attribute | Description | Default | Required? |
---|---|---|---|
name | The name of the column. | The property or field name. | No |
unique | Whether the column 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 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. | false | No |
nullable | Whether the database column is nullable. | true | No |
insertable | Whether the column is included in SQL INSERT statements generated by the persistence provider. | true | No |
updatable | Whether the column is included in SQL UPDATE statements generated by the persistence provider. | true | No |
columnDefinition | The SQL fragment that is used when generating the DDL for the column. | Generated SQL to create a column of the inferred type. | No |
table | The name of the table that contains the column. If absent the column is assumed to be in the primary table for the mapped object. | Column is in primary table. | No |
length | The column length. (Applies only if a string-valued column is used.) | 255 | No |
precision | The precision for a decimal (exact numeric) column. (Applies only if a decimal column is used.) | 0 (Value must be set by developer.) | No |
scale | The scale for a decimal (exact numeric) column. (Applies only if a decimal column is used.) | 0 | No |
The following example shows how to use the @Column annotation, with values to override the defaults for updatable, precision, and scale.
@Column(name="ORDER_COST", updatable=false, precision=12, scale=2) public BigDecimal getCost() { return cost; }