Search in sources :

Example 1 with Converter

use of javax.persistence.Converter in project hibernate-orm by hibernate.

the class AttributeConverterDefinition method from.

/**
	 * Build an AttributeConverterDefinition from an AttributeConverter instance.  The
	 * converter is searched for a {@link Converter} annotation	 to determine whether it should
	 * be treated as auto-apply.  If the annotation is present, {@link Converter#autoApply()} is
	 * used to make that determination.  If the annotation is not present, {@code false} is assumed.
	 *
	 * @param attributeConverter The AttributeConverter instance
	 *
	 * @return The constructed definition
	 */
public static AttributeConverterDefinition from(AttributeConverter attributeConverter) {
    boolean autoApply = false;
    Converter converterAnnotation = attributeConverter.getClass().getAnnotation(Converter.class);
    if (converterAnnotation != null) {
        autoApply = converterAnnotation.autoApply();
    }
    return new AttributeConverterDefinition(attributeConverter, autoApply);
}
Also used : AttributeConverter(javax.persistence.AttributeConverter) Converter(javax.persistence.Converter)

Aggregations

AttributeConverter (javax.persistence.AttributeConverter)1 Converter (javax.persistence.Converter)1