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.TYPE; 016import static java.lang.annotation.RetentionPolicy.RUNTIME; 017 018/** 019 * Specifies the primary table for the annotated entity. Additional tables may be specified using 020 * {@link SecondaryTable} or {@link SecondaryTables} annotation. 021 * <p> 022 * If no <code>Table</code> annotation is specified for an entity class, the default values apply. 023 * <p> 024 * <pre> 025 * Example: 026 * 027 * @Entity 028 * @Table(name="CUST", schema="RECORDS") 029 * public class Customer { ... } 030 * </pre> 031 * 032 * @since Java Persistence 1.0 033 */ 034@Target(TYPE) 035@Retention(RUNTIME) 036public @interface Table { 037 /** 038 * (Optional) The name of the table. Defaults to the entity name. 039 * 040 * @return name 041 */ 042 String name() default ""; 043 044 /** 045 * (Optional) The catalog of the table. Defaults to the default catalog. 046 * 047 * @return catalog 048 */ 049 String catalog() default ""; 050 051 /** 052 * (Optional) The schema of the table. Defaults to the default schema for user. 053 * 054 * @return schema 055 */ 056 String schema() default ""; 057 058 /** 059 * (Optional) Unique constraints that are to be placed on the table. These are only used if table 060 * generation is in effect. These constraints apply in addition to any constraints specified by the 061 * <code>Column</code> and <code>JoinColumn</code> annotations and constraints entailed by primary key 062 * mappings. Defaults to no additional constraints. 063 * 064 * @return unique constrs 065 */ 066 UniqueConstraint[] uniqueConstraints() default {}; 067 068 /** 069 * (Optional) Indexes for the table. These are only used if table generation is in effect. Defaults to no 070 * additional indexes. 071 * 072 * @return The indexes 073 */ 074 Index[] indexes() default {}; 075}