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; 018 019/** 020 * This annotation must be specified for persistent map keys of type {@link java.util.Date} and 021 * {@link java.util.Calendar}. It may only be specified for map keys of these types. 022 * <p> 023 * The <code>MapKeyTemporal</code> annotation can be applied to an element collection or relationship of type 024 * <code>java.util.Map</code> in conjunction with the <code>ElementCollection</code>, <code>OneToMany</code>, 025 * or <code>ManyToMany</code> annotation. 026 * <p> 027 * <pre> 028 * Example: 029 * 030 * @OneToMany 031 * @MapKeyTemporal(DATE) 032 * protected java.util.Map<java.util.Date, Employee> employees; 033 * </pre> 034 * 035 * @since Java Persistence 2.0 036 */ 037@Target({METHOD, FIELD}) 038@Retention(RUNTIME) 039public @interface MapKeyTemporal { 040 /** 041 * (Required) The type used in mapping <code>java.util.Date</code> or <code>java.util.Calendar</code>. 042 * 043 * @return The type used 044 */ 045 TemporalType value(); 046}