Basic mapping

Use a Basic Mapping to map an attribute directly to a database column. Basic mappings may be used only with the following attribute types:

To create a basic mapping:

  1. In the JPA Structure view, select the field to map. The JPA Details view (for attributes) displays the properties for the selected field.

  2. In the Map As field, select Basic.

  3. Use this table to complete the remaining fields on the JPA Details view.

    Property Description Default
    Map As Defines this mapping as a Basic Mapping.

    This field corresponds to the @Basic annotation.

    Basic
    Column The database column mapped to the entity attribute. See "Column" for details.
    • Name – Name of the database column.

    • Table – Name of the database table.

    • Insertable – Specify if the column is always included in SQL INSERT statements.

    • Updatable – Specify if the column is always included in SQL UPDATE statements.

    By default, the Column is assumed to be named identically to the attribute and always included in the INSERT and UPDATE statements.
    Table Name of the database table.
    Fetch Defines how data is loaded from the database. See "Fetch Type" for details.
    • Eager

    • Lazy

    Eager
    Optional Specifies if this field is can be null. Yes
    Lob Specifies if this is a large objects (BLOB or CLOB). See "Lob" for details.
    Temporal Specifies the type of data. See "Temporal" for details.
    • Date

    • Time

    • Timestamp



Eclipse adds the following annotations to the field:

@Column(name="<COLUMN_NAME>", table="<COLUMN_TABLE>", 
    insertable=<INSERTABLE>, updatable=<UPDATABLE>)
@Basic(fetch=FetchType.<FETCH_TYPE>, optional = <OPTIONAL>)
@Temporal(TemporalType.<TEMPORAL>)


 

Related task

Mapping an entity

 

Related reference

JPA Structure view
JPA Details view (for attributes)

 

Related concept

Understanding OR mappings
Understanding EJB 3.0 Java Persistence API