@Basic
From CauchoWiki
The @Basic annotation is the simplest mapping to a database column. It represents a Java primitive value or a Serializable value.
@Basic
public String getData() { return _data; }
The @Basic annotation is optional for fields and properties, i.e. a field without a @Basic annotation (and without a @Transient annotation) is assumed to have a @Basic annotation.
[edit] Property Types
The @Basic annotation may be used for the following types:
- Java primitives (boolean, byte, int, double, etc.)
- String
- BigDecimal
- BigInteger
- java.util.Date
- java.util.Calendar
- java.sql.Date
- java.sql.Time
- java.sql.Timestamp
- byte[], Byte[], char[], Character[]
- enums
- Serializable
[edit] Annotation Definition
public @interface Basic {
FetchType fetch() default EAGER;
boolean optional() default true;
}
The EAGER FetchType is a hint to Amber that the field should be fetched along with the rest of the entity. The LAZY fetch type is a hint that Amber can wait until the field is used before loading it from the database.
The optional value indicates that the field is Nullable in the database. Java primitives are never optional.
[edit] Related Annotations
The following annotations can be used in combination with @Basic.
- @Column specifies database column name and definition
- @Lob indicates that the database will store the object as a large object (blob or clob)
- @Temporal specifies the database TemporalType for date and time fields.
- @Enumerated specifies the EnumerationType for storing enum values.
