-
@Target(TYPE) @Retention(RUNTIME) public @interface Converter
Declares that the annotated class is a converter and specifies whether the converter is automatically applied.Every converter class must implement
AttributeConverter
and must be annotated with theConverter
annotation or declared as a converter in the object/relational mapping descriptor. The target type for a converter is determined by the actual type argument of the first type parameter ofAttributeConverter
.If
autoApply = true
, the persistence provider must automatically apply the converter to every mapped attribute of the specified target type belonging to any entity in the persistence unit, except for attributes for which conversion is overridden by means of theConvert
annotation (or XML equivalent). TheConvert
annotation may be used to override or disable auto-apply conversion on a per-attribute basis.- In determining whether a converter applies to an attribute, the provider must treat primitive types and wrapper types as equivalent.
- A converter never applies to id attributes,
version attributes, relationship attributes,
or to attributes explicitly annotated
Enumerated
orTemporal
(or designated as such via XML). - A converter never applies to any attribute annotated
@Convert(disableConversion=true)
, or to an attribute for which theConvert
annotation explicitly specifies a different converter.
If
autoApply = false
, the converter applies only to attributes of the target type for which conversion is explicitly enabled via theConvert
annotation (or corresponding XML element).If there is more than one converter defined for the same target type,
Convert.converter()
must be used to explicitly specify which converter applies.- Since:
- 2.1
- See Also:
AttributeConverter
,Convert
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description boolean
autoApply
Specifies whether the annotated converter should be automatically applied to attributes of the target type.
-