-
@Target(value={METHOD,FIELD}) @Retention(value=RUNTIME) public @interface Basic
The simplest type of mapping to a database column. TheBasic
annotation can be applied to a persistent property or instance variable of any of the following types: Java primitive types, wrappers of the primitive types,String
,java.math.BigInteger
,java.math.BigDecimal
,java.util.Date
,java.util.Calendar
,java.sql.Date
,java.sql.Time
,java.sql.Timestamp
,byte[]
,Byte[]
,char[]
,Character[]
, enums, and any other type that implementsjava.io.Serializable
.The use of the
Basic
annotation is optional for persistent fields and properties of these types. If theBasic
annotation is not specified for such a field or property, the default values of theBasic
annotation will apply.Example 1: @Basic protected String name; Example 2: @Basic(fetch=LAZY) protected String getName() { return name; }
- Since:
- Java Persistence 1.0
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element and Description FetchType
fetch
(Optional) Defines whether the value of the field or property should be lazily loaded or must be eagerly fetched.boolean
optional
(Optional) Defines whether the value of the field or property may be null.
-
-
-
Element Detail
-
fetch
public abstract FetchType fetch
(Optional) Defines whether the value of the field or property should be lazily loaded or must be eagerly fetched. TheEAGER
strategy is a requirement on the persistence provider runtime that the value must be eagerly fetched. TheLAZY
strategy is a hint to the persistence provider runtime. If not specified, defaults toEAGER
.- Default:
- javax.persistence.FetchType.EAGER
-
-
Document created the 11/06/2005, last modified the 18/08/2025
Source of the printed document:https://www.gaudry.be/en/java-api-javaee-rf-javax/persistence/Basic.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author of this site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.