Jump to: navigation, search

Difference between revisions of "EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Basic Mappings/Basic"

(New page: {{EclipseLink_UserGuide |info=y |toc=n |eclipselink=y |eclipselinktype=JPA}} ==@Basic== By default, EclipseLink persistence provider automatically configures <tt>@Basic</tt> mapping for m...)
Line 61: Line 61:
|previous=[[EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Entity/Id|Id]]
|previous=[[EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Basic Mappings|Basic Mappings]]
|next=[[EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Basic Mappings/Enumerated|@Enumerated]]
|next=[[EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Basic Mappings/Enumerated|@Enumerated]]
|up=[[EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping|Mapping]]
|up=[[EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping|Mapping]]
|version=2.2.0 DRAFT}}
|version=2.2.0 DRAFT}}

Revision as of 11:58, 15 February 2011

EclipseLink JPA

Mailing ListForumsIRC
Help Wanted
Bug Day
Browse Source


By default, EclipseLink persistence provider automatically configures @Basic mapping for most Java primitive types, wrappers of the primitive types, and enumerated types.

EclipseLink uses the default column name format of <field-name> or <property-name> in uppercase characters.

You may explicitly place an optional @Basic annotation on a field or property to explicitly mark it as persistent.

Elug note icon.png

Note: The @Basic annotation is mostly for documentation purposes – it is not required for the field or property to be persistent.

Use the @Basic annotation to do the following:

  • configure the fetch type to LAZY;
  • configure the mapping to forbid null values (for nonprimitive types) in case null values are inappropriate for your application.
@Basic Attributes
Attribute Description Default Required?
fetch By default, EclipseLink persistence provider uses a fetch type of javax.persitence.FetchType.EAGER: data must be eagerly fetched. If necessary, you can set fetch to FetchType.LAZY: this is a hint to the persistence provider that data should be fetched lazily when it is first accessed (if possible). Eager No
optional By default, EclipseLink persistence provider assumes that the value of all (nonprimitive) fields and properties are optional and may be null. True No

This example shows how to use this annotation to specify a fetch type of LAZY for a basic mapping.

Usage of the @Basic Annotation

 public class Employee implements Serializable {
     protected String getName() {
         return name;

For more information and examples, see Section 9.1.18 "Basic Annotation" of the JPA Specification.

For more information on EclipseLink direct mappings and relationship mappings, see Relational Mapping Types.

Version: 2.2.0 DRAFT
Other versions...