The Basic annotation may be applied to a property or
instance variable whose type is any one of the following:
String,
java.math.BigInteger or java.math.BigDecimal ,
java.time.LocalDate , java.time.LocalTime ,
java.time.LocalDateTime , java.time.OffsetTime ,
java.time.OffsetDateTime , java.time.Instant ,
or java.time.Year
java.util.Date or java.util.Calendar ,
java.sql.Date, java.sql.Time,
or java.sql.Timestamp,
byte[] or Byte[],
char[] or Character[],
enum type, or
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:
@Basic
protected String name;
Example 2:
@Basic(fetch = LAZY)
protected String getName() { return name; }
The use of java., java.,
java.sql.Date, java.sql.Time, java.sql.Timestamp,
Character[], or Byte[] as the type of a basic attribute
is now discouraged. Newly-written code should use the date/time types
defined in the package java.time, or the primitive array types
char[] and byte[].
| Modifier and Type | Method and Description |
|---|---|
| public FetchType | fetch()
(Optional) Whether the value of the field or property should be lazily loaded or must be eagerly fetched. |
| public boolean |
| fetch | back to summary |
|---|---|
| public FetchType fetch() (Optional) Whether the value of the field or property should be lazily loaded or must be eagerly fetched.
If not specified, defaults to | |
| optional | back to summary |
|---|---|
| public boolean optional() (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 If not specified, defaults to | |