JPA Annotation

Basic

Target: METHOD, FIELD
Implemented Interfaces:
Annotation

The simplest type of mapping of a persistent field or property to a single database column.

The Basic annotation may be applied to a property or instance variable whose type is any one of the following:

The use of the Basic annotation is optional for persistent fields and properties of these types. If the Basic annotation is not specified for such a field or property, the default values of the Basic annotation apply.

The database column mapped by the persistent field or property may be specified using the Column annotation.

Example 1:

 {@snippet :
Since:
JPA 1.0

Public Annotation Attributes

FetchType fetch default FetchType.EAGER
(Optional) Whether the value of the field or property should be lazily loaded or must be eagerly fetched.
  • The EAGER strategy is a requirement on the persistence provider runtime that the associated entity must be eagerly fetched.
  • The LAZY strategy is a hint to the persistence provider runtime.

If not specified, defaults to EAGER.

Since:
JPA 1.0
boolean optional default true
(Optional) Specifies whether the value of the field or property may be null.

This is a hint and is disregarded for primitive types; it may be used in schema generation to infer that the mapped column is not null.

If not specified, defaults to true.

Since:
JPA 1.0