Basic (Java EE 5)

Java EE API


javax.persistence Annotation Type Basic


@Target(value={METHOD,FIELD})
@Retention(value=RUNTIME)
public @interface Basic

Implements: Annotation
@Target(value={METHOD, FIELD})
@Retention(value=RUNTIME)

Basic 注释是数据库列最简单的映射类型。Basic 注释可以应用于以下任意类型的持久属性或实例变量:Java 基本类型、基本类型的包装器、Stringjava.math.BigIntegerjava.math.BigDecimaljava.util.Datejava.util.Calendarjava.sql.Datejava.sql.Timejava.sql.Timestampbyte[], Byte[], char[], Character[]、枚举以及任何实现 Serializable 的其他类型。

对于这些类型的持久字段和属性,使用 Basic 注释是可选的。

英文文档:

The Basic annotation is the simplest type of mapping to a database column. The Basic 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 implements Serializable.

The use of the Basic annotation is optional for persistent fields and properties of these types.

Since:
Java Persistence 1.0

Optional Element Summary
 FetchType
 boolean
 

abstract public FetchType fetch()
(可选)定义字段或属性的值是应该延迟加载还是必须立即获取。使用 EAGER 战略是必须立即获取值的持久性提供者运行时的要求。LAZY 战略是持久性提供者运行时的提示。如果没有指定,则默认为 EAGER
英文文档:

fetch

public abstract FetchType fetch
(Optional) Defines whether the value of the field or property should be lazily loaded or must be eagerly fetched. The EAGER strategy is a requirement on the persistence provider runtime that the value must be eagerly fetched. The LAZY strategy is a hint to the persistence provider runtime. If not specified, defaults to EAGER.

Default:
EAGER

abstract public boolean optional()
(可选)定义字段或属性的值是否可以为 null。这是一个提示,基础类型可以忽略;它可以用于模式生成。如果没有指定,则默认为 true
英文文档:

optional

public abstract boolean optional
(Optional) Defines 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. If not specified, defaults to true.

Default:
true


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!