-
@Target({METHOD,FIELD}) @Retention(RUNTIME) public @interface BasicThe simplest type of mapping of a persistent field or property to a single database column.The
Basicannotation may be applied to a property or instance variable whose type is any one of the following:- a Java primitive type, or wrapper of a primitive type,
String,BigIntegerorBigDecimal,LocalDate,LocalTime,LocalDateTime,OffsetTime,OffsetDateTime,Instant, orYearDateorCalendar,java.sql.Date,java.sql.Time, orjava.sql.Timestamp,byte[]orByte[],char[]orCharacter[],- a Java
enumtype, or - any other serializable type.
The use of the
Basicannotation is optional for persistent fields and properties of these types. If theBasicannotation is not specified for such a field or property, the default values of theBasicannotation apply.The database column mapped by the persistent field or property may be specified using the
Columnannotation.Example 1: {@snippet :
- Since:
- 1.0
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description FetchTypefetch(Optional) Whether the value of the field or property should be lazily loaded or must be eagerly fetched.booleanoptional(Optional) Specifies whether the value of the field or property may be null.
-
-
-
Element Detail
-
fetch
FetchType fetch
(Optional) Whether the value of the field or property should be lazily loaded or must be eagerly fetched.- The
EAGERstrategy is a requirement on the persistence provider runtime that the associated entity must be eagerly fetched. - The
LAZYstrategy is a hint to the persistence provider runtime.
If not specified, defaults to
EAGER.- Default:
- jakarta.persistence.FetchType.EAGER
- The
-
-
-
optional
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
not null.If not specified, defaults to
true.- Default:
- true
-
-