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.FIELD; 016import static java.lang.annotation.RetentionPolicy.RUNTIME; 017import static javax.persistence.EnumType.ORDINAL; 018 019/** 020 * Specifies that a persistent property or field should be persisted 021 * as a enumerated type. The <code>Enumerated</code> annotation may 022 * be used in conjunction with the <code>Basic</code> annotation, or in 023 * conjunction with the <code>ElementCollection</code> annotation when the 024 * element collection value is of basic type. If the enumerated type 025 * is not specified or the <code>Enumerated</code> annotation is not 026 * used, the <code>EnumType</code> value is assumed to be <code>ORDINAL</code>. 027 * <p> 028 * <pre> 029 * Example: 030 * 031 * public enum EmployeeStatus {FULL_TIME, PART_TIME, CONTRACT} 032 * 033 * public enum SalaryRate {JUNIOR, SENIOR, MANAGER, EXECUTIVE} 034 * 035 * @Entity public class Employee { 036 * public EmployeeStatus getStatus() {...} 037 * ... 038 * @Enumerated(STRING) 039 * public SalaryRate getPayScale() {...} 040 * ... 041 * } 042 * </pre> 043 * 044 * @see Basic 045 * @see ElementCollection 046 * @since Java Persistence 1.0 047 */ 048@Target({FIELD}) 049@Retention(RUNTIME) 050public @interface Enumerated { 051 052 EnumType value() default ORDINAL; 053}