All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javax.persistence.Basic Maven / Gradle / Ivy

There is a newer version: 2.2.1
Show newest version
/*******************************************************************************
 * Copyright (c) 2008, 2009 Sun Microsystems. All rights reserved. 
 * 
 * This program and the accompanying materials are made available under the 
 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 
 * which accompanies this distribution. 
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
 * and the Eclipse Distribution License is available at 
 * http://www.eclipse.org/org/documents/edl-v10.php.
 * 
 * Contributors:
 *     Linda DeMichiel - Java Persistence 2.0 - Version 2.0 (October 1, 2009)
 *     Specification available from http://jcp.org/en/jsr/detail?id=317
 *
 ******************************************************************************/
package javax.persistence;

import java.lang.annotation.Target;
import java.lang.annotation.Retention;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static javax.persistence.FetchType.EAGER;

/**
 * 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 java.io.Serializable.
 * 
 * 

The use of the Basic annotation is optional for * persistent fields and properties of these types. If the * Basic annotation is not specified for such a field or * property, the default values of the Basic annotation * will apply. * *

 *    Example 1:
 *
 *    @Basic
 *    protected String name;
 *
 *    Example 2:
 *
 *    @Basic(fetch=LAZY)
 *    protected String getName() { return name; }
 *
 * 
* @since Java Persistence 1.0 */ @Target({METHOD, FIELD}) @Retention(RUNTIME) public @interface Basic { /** * (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. */ FetchType fetch() default EAGER; /** * (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. */ boolean optional() default true; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy