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

javax.persistence.GeneratedValue Maven / Gradle / Ivy

The newest version!
/*
 * The contents of this file are subject to the terms 
 * of the Common Development and Distribution License 
 * (the "License").  You may not use this file except 
 * in compliance with the License.
 * 
 * You can obtain a copy of the license at 
 * glassfish/bootstrap/legal/CDDLv1.0.txt or 
 * https://glassfish.dev.java.net/public/CDDLv1.0.html. 
 * See the License for the specific language governing 
 * permissions and limitations under the License.
 * 
 * When distributing Covered Code, include this CDDL 
 * HEADER in each file and include the License file at 
 * glassfish/bootstrap/legal/CDDLv1.0.txt.  If applicable, 
 * add the following below this CDDL HEADER, with the 
 * fields enclosed by brackets "[]" replaced with your 
 * own identifying information: Portions Copyright [yyyy] 
 * [name of copyright owner]
 */
package javax.persistence;

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

/**
 * Provides for the specification of generation strategies for 
 * the values of primary keys. The GeneratedValue 
 * annotation may be applied to a primary key property or
 * field of an entity or mapped superclass in conjunction with 
 * the {@link Id} annotation.
 *
 * 
 *
 * Example 1:
 *
 *     @Id
 *     @GeneratedValue(strategy=SEQUENCE, generator="CUST_SEQ")
 *     @Column(name="CUST_ID")
 *     public Long getId() { return id; }
 *
 *     Example 2:
 *
 *     @Id
 *     @GeneratedValue(strategy=TABLE, generator="CUST_GEN")
 *     @Column(name="CUST_ID")
 *     Long id;
 * 
* * @since Java Persistence 1.0 */ @Target({METHOD, FIELD}) @Retention(RUNTIME) public @interface GeneratedValue { /** * (Optional) The primary key generation strategy * that the persistence provider must use to * generate the annotated entity primary key. */ GenerationType strategy() default AUTO; /** * (Optional) The name of the primary key generator * to use as specified in the {@link SequenceGenerator} * or {@link TableGenerator} annotation. *

Defaults to the id generator supplied by persistence provider. */ String generator() default ""; }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy