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.RetentionPolicy.RUNTIME; 017 018/** 019 * Specifies the primary key of an entity. 020 * The field or property to which the <code>Id</code> annotation is applied 021 * should be one of the following types: any Java primitive type; 022 * any primitive wrapper type; 023 * <code>String</code>; 024 * <code>java.util.Date</code>; 025 * <code>java.sql.Date</code>; 026 * <code>java.math.BigDecimal</code>; 027 * <code>java.math.BigInteger</code>. 028 * <p> 029 * <p>The mapped column for the primary key of the entity is assumed 030 * to be the primary key of the primary table. If no <code>Column</code> annotation 031 * is specified, the primary key column name is assumed to be the name 032 * of the primary key property or field. 033 * <p> 034 * <pre> 035 * Example: 036 * 037 * @Id 038 * Long id; 039 * </pre> 040 * 041 * @see Column 042 * @see GeneratedValue 043 * @since Java Persistence 1.0 044 */ 045@Target({FIELD}) 046@Retention(RUNTIME) 047 048public @interface Id { 049}