1 /* 2 * The contents of this file are subject to the terms 3 * of the Common Development and Distribution License 4 * (the License). You may not use this file except in 5 * compliance with the License. 6 * 7 * You can obtain a copy of the license at 8 * https://glassfish.dev.java.net/public/CDDLv1.0.html or 9 * glassfish/bootstrap/legal/CDDLv1.0.txt. 10 * See the License for the specific language governing 11 * permissions and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL 14 * Header Notice in each file and include the License file 15 * at glassfish/bootstrap/legal/CDDLv1.0.txt. 16 * If applicable, add the following below the CDDL Header, 17 * with the fields enclosed by brackets [] replaced by 18 * you own identifying information: 19 * "Portions Copyrighted [year] [name of copyright owner]" 20 * 21 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 22 */ 23 package javax.persistence; 24 25 import java.lang.annotation.Target; 26 import java.lang.annotation.Retention; 27 import static java.lang.annotation.ElementType.TYPE; 28 import static java.lang.annotation.RetentionPolicy.RUNTIME; 29 30 /** 31 * Is used to specify the value of the discriminator column for 32 * entities of the given type. The <code>DiscriminatorValue</code> 33 * annotation can only be specified on a concrete entity 34 * class. If the <code>DiscriminatorValue</code> annotation is not 35 * specified and a discriminator column is used, a provider-specific 36 * function will be used to generate a value representing the 37 * entity type. If the {@link DiscriminatorType} is {@link 38 * DiscriminatorType#STRING STRING}, the discriminator value 39 * default is the entity name. 40 * 41 * <p> The inheritance strategy and the discriminator column 42 * are only specified in the root of an entity class hierarchy 43 * or subhierarchy in which a different inheritance strategy is 44 * applied. The discriminator value, if not defaulted, should be 45 * specified for each entity class in the hierarchy. 46 * 47 * <pre> 48 * 49 * Example: 50 * 51 * @Entity 52 * @Table(name="CUST") 53 * @Inheritance(strategy=SINGLE_TABLE) 54 * @DiscriminatorColumn(name="DISC", discriminatorType=STRING,length=20) 55 * @DiscriminatorValue("CUSTOMER") 56 * public class Customer { ... } 57 * 58 * @Entity 59 * @DiscriminatorValue("VCUSTOMER") 60 * public class ValuedCustomer extends Customer { ... } 61 * </pre> 62 * 63 * @since Java Persistence 1.0 64 */ 65 @Target({TYPE}) 66 @Retention(RUNTIME) 67 68 public @interface DiscriminatorValue { 69 70 /** 71 * (Optional) The value that indicates that the 72 * row is an entity of the annotated entity type. 73 * 74 * <p> If the <code>DiscriminatorValue</code> annotation is not 75 * specified and a discriminator column is used, a provider-specific 76 * function will be used to generate a value representing the 77 * entity type. If the DiscriminatorType is {@link 78 * DiscriminatorType#STRING STRING}, the discriminator value 79 * default is the entity name. 80 */ 81 String value(); 82 } 83