Annotation Interface Converter


@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 the Converter 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 of AttributeConverter.

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 the Convert annotation (or XML equivalent). The Convert 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 or Temporal (or designated as such via XML).
  • A converter never applies to any attribute annotated @Convert(disableConversion=true), or to an attribute for which the Convert 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 the Convert 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: