001/*
002 * Copyright (c) 2008, 2009, 2011 Oracle, Inc. All rights reserved.
003 *
004 * This program and the accompanying materials are made available under the
005 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
006 * which accompanies this distribution.  The Eclipse Public License is available
007 * at http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution License
008 * is available at http://www.eclipse.org/org/documents/edl-v10.php.
009 */
010package javax.persistence;
011
012import java.lang.annotation.Retention;
013import java.lang.annotation.Target;
014
015import static java.lang.annotation.ElementType.FIELD;
016import static java.lang.annotation.ElementType.METHOD;
017import static java.lang.annotation.RetentionPolicy.RUNTIME;
018
019/**
020 * Specifies the primary key of an entity.
021 * The field or property to which the <code>Id</code> annotation is applied
022 * should be one of the following types: any Java primitive type;
023 * any primitive wrapper type;
024 * <code>String</code>;
025 * <code>java.util.Date</code>;
026 * <code>java.sql.Date</code>;
027 * <code>java.math.BigDecimal</code>;
028 * <code>java.math.BigInteger</code>.
029 * <p>
030 * <p>The mapped column for the primary key of the entity is assumed
031 * to be the primary key of the primary table. If no <code>Column</code> annotation
032 * is specified, the primary key column name is assumed to be the name
033 * of the primary key property or field.
034 * <p>
035 * <pre>
036 *   Example:
037 *
038 *   &#064;Id
039 *   public Long getId() { return id; }
040 * </pre>
041 *
042 * @see Column
043 * @see GeneratedValue
044 * @since Java Persistence 1.0
045 */
046@Target({METHOD, FIELD})
047@Retention(RUNTIME)
048
049public @interface Id {
050}