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