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 multiple secondary tables for an entity. 020 * <p> 021 * <pre> 022 * Example 1: Multiple secondary tables assuming primary key columns are named the same in all tables. 023 * 024 * @Entity 025 * @Table(name="EMPLOYEE") 026 * @SecondaryTables({ 027 * @SecondaryTable(name="EMP_DETAIL"), 028 * @SecondaryTable(name="EMP_HIST") 029 * }) 030 * public class Employee { ... } 031 * 032 * 033 * Example 2: Multiple secondary tables with differently named primary key columns. 034 * 035 * @Entity 036 * @Table(name="EMPLOYEE") 037 * @SecondaryTables({ 038 * @SecondaryTable(name="EMP_DETAIL", 039 * pkJoinColumns=@PrimaryKeyJoinColumn(name="EMPL_ID")), 040 * @SecondaryTable(name="EMP_HIST", 041 * pkJoinColumns=@PrimaryKeyJoinColumn(name="EMPLOYEE_ID")) 042 * }) 043 * public class Employee { ... } 044 * </pre> 045 * 046 * @since Java Persistence 1.0 047 */ 048@Target(TYPE) 049@Retention(RUNTIME) 050 051public @interface SecondaryTables { 052 SecondaryTable[] value(); 053}