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.Repeatable; 013import java.lang.annotation.Retention; 014import java.lang.annotation.Target; 015 016import static java.lang.annotation.ElementType.*; 017import static java.lang.annotation.RetentionPolicy.RUNTIME; 018 019/** 020 * The Convert annotation is used to specify the conversion of a Basic field or 021 * property. It is not necessary to use the Basic annotation or corresponding XML 022 * element to specify the basic type. 023 * 024 * @since Java Persistence 2.1 025 */ 026@Target({METHOD, FIELD, TYPE}) 027@Retention(RUNTIME) 028@Repeatable(Converts.class) 029public @interface Convert { 030 /** 031 * Specifies the converter to be applied. A value for this 032 * element must be specified if multiple converters would 033 * otherwise apply. 034 * 035 * @return converter 036 */ 037 Class converter() default void.class; 038 039 /** 040 * The attributeName must be specified unless the Convert annotation 041 * is on an attribute of basic type or on an element collection of 042 * basic type. In these cases, attributeName must not be 043 * specified. 044 * 045 * @return attribute name 046 */ 047 String attributeName() default ""; 048 049 /** 050 * Used to disable an auto-apply or inherited converter. 051 * If disableConversion is true, the converter element should 052 * not be specified. 053 * 054 * @return disable 055 */ 056 boolean disableConversion() default false; 057}