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 value of the discriminator column for
020 * entities of the given type.
021 * <p>
022 * <p> The <code>DiscriminatorValue</code>
023 * annotation can only be specified on a concrete entity
024 * class.
025 * <p>
026 * <p> If the <code>DiscriminatorValue</code> annotation is not
027 * specified and a discriminator column is used, a provider-specific
028 * function will be used to generate a value representing the
029 * entity type.  If the {@link DiscriminatorType} is <code>
030 * STRING</code>, the discriminator value
031 * default is the entity name.
032 * <p>
033 * <p> The inheritance strategy and the discriminator column
034 * are only specified in the root of an entity class hierarchy
035 * or subhierarchy in which a different inheritance strategy is
036 * applied. The discriminator value, if not defaulted, should be
037 * specified for each entity class in the hierarchy.
038 * <p>
039 * <pre>
040 *
041 *    Example:
042 *
043 *    &#064;Entity
044 *    &#064;Table(name="CUST")
045 *    &#064;Inheritance(strategy=SINGLE_TABLE)
046 *    &#064;DiscriminatorColumn(name="DISC", discriminatorType=STRING, length=20)
047 *    &#064;DiscriminatorValue("CUSTOMER")
048 *    public class Customer { ... }
049 *
050 *    &#064;Entity
051 *    &#064;DiscriminatorValue("VCUSTOMER")
052 *    public class ValuedCustomer extends Customer { ... }
053 * </pre>
054 *
055 * @see DiscriminatorColumn
056 * @since Java Persistence 1.0
057 */
058@Target({TYPE})
059@Retention(RUNTIME)
060public @interface DiscriminatorValue {
061
062  /**
063   * (Optional) The value that indicates that the
064   * row is an entity of the annotated entity type.
065   * <p>
066   * <p> If the <code>DiscriminatorValue</code> annotation is not
067   * specified and a discriminator column is used, a
068   * provider-specific function will be used to generate a value
069   * representing the entity type.  If the <code>DiscriminatorType</code> is
070   * <code>STRING</code>, the discriminator value default is the
071   * entity name.
072   *
073   * @return value
074   */
075  String value();
076}