2.5.2.7. Basic

Basic signifies a standard value persisted as-is to the datastore. You can use the Basic annotation on persistent fields of the following types: primitives, primitive wrappers, java.lang.String, byte[], Byte[], char[], Character[], java.math.BigDecimal, java.math.BigInteger, java.util.Date, java.util.Calendar, java.sql.Date, java.sql.Timestamp, java.sql.Time, Enums, and Serializable types.

Since JPA 2.2 the following java.time Types are also supported: java.time.LocalDate, java.time.LocalDateTime, java.time.LocalTime, java.time.LocalOffsetTime and java.time.OffsetDateTime.

Since JPA 3.1, java.util.UUID is also supported.

Basic declares these properties:

  • FetchType fetch: Whether to load the field eagerly (FetchType.EAGER) or lazily (FetchType.LAZY). Defaults to FetchType.EAGER.

  • boolean optional: Whether the datastore allows null values. Defaults to true.

The equivalent XML element is basic. It has the following attributes:

  • name: The name of the field or property. This attribute is required.

  • fetch: One of EAGER or LAZY.

  • optional: Boolean indicating whether the field value may be null.