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; 017import static javax.persistence.InheritanceType.SINGLE_TABLE; 018 019/** 020 * Defines the inheritance strategy to be used for an entity class 021 * hierarchy. It is specified on the entity class that is the root of 022 * the entity class hierarchy. If the <code>Inheritance</code> annotation is not 023 * specified or if no inheritance type is specified for an entity 024 * class hierarchy, the <code>SINGLE_TABLE</code> mapping strategy is used. 025 * <p> 026 * <pre> 027 * 028 * Example: 029 * 030 * @Entity 031 * @Inheritance(strategy=JOINED) 032 * public class Customer { ... } 033 * 034 * @Entity 035 * public class ValuedCustomer extends Customer { ... } 036 * </pre> 037 * 038 * @since Java Persistence 1.0 039 */ 040@Target({TYPE}) 041@Retention(RUNTIME) 042 043public @interface Inheritance { 044 045 /** 046 * The strategy to be used for the entity inheritance hierarchy. 047 * 048 * @return strategy 049 */ 050 InheritanceType strategy() default SINGLE_TABLE; 051}