KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > persistence > Basic


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package javax.persistence;
24
25 import java.lang.annotation.Target JavaDoc;
26 import java.lang.annotation.Retention JavaDoc;
27 import static java.lang.annotation.ElementType.TYPE JavaDoc;
28 import static java.lang.annotation.ElementType.METHOD JavaDoc;
29 import static java.lang.annotation.ElementType.FIELD JavaDoc;
30 import static java.lang.annotation.RetentionPolicy.RUNTIME JavaDoc;
31 import static javax.persistence.FetchType.EAGER;
32
33 /**
34  * The <code>Basic</code> annotation is the simplest type of mapping
35  * to a database column. The <code>Basic</code> annotation can be
36  * applied to a persistent property or instance variable of any of the
37  * following types: Java primitive types, wrappers of the primitive types,
38  * {@link String}, {@link java.math.BigInteger java.math.BigInteger},
39  * {@link java.math.BigDecimal java.math.BigDecimal},
40  * {@link java.util.Date java.util.Date},
41  * {@link java.util.Calendar java.util.Calendar},
42  * {@link java.sql.Date java.sql.Date}, {@link java.sql.Time java.sql.Time},
43  * {@link java.sql.Timestamp java.sql.Timestamp}, <code>byte[], Byte[],
44  * char[], Character[]</code>, enums, and any other type that implements
45  * {@link java.io.Serializable Serializable}.
46  *
47  * <p> The use of the <code>Basic</code> annotation is optional for
48  * persistent fields and properties of these types.
49  *
50  * @since Java Persistence 1.0
51  */

52 @Target JavaDoc({METHOD, FIELD})
53 @Retention JavaDoc(RUNTIME)
54 public @interface Basic {
55
56     /**
57      * (Optional) Defines whether the value of the field or property should
58      * be lazily loaded or must be eagerly fetched. The <code>EAGER</code>
59      * strategy is a requirement on the persistence provider runtime
60      * that the value must be eagerly fetched. The <code>LAZY</code>
61      * strategy is a hint to the persistence provider runtime.
62      * If not specified, defaults to <code>EAGER</code>.
63      */

64     FetchType fetch() default EAGER;
65
66     /**
67      * (Optional) Defines whether the value of the field or property may be null.
68      * This is a hint and is disregarded for primitive types; it may
69      * be used in schema generation.
70      * If not specified, defaults to <code>true</code>.
71      */

72     boolean optional() default true;
73 }
74
Popular Tags