List of usage examples for javax.persistence AttributeConverter convertToEntityAttribute
public X convertToEntityAttribute(Y dbData);
From source file:org.kuali.rice.krad.data.jpa.Filter.java
/** * Uses the {@link Convert} converter to first translate the {@code attributeValue} to the desired type and then * convert it to the database format for searching. * * @param convert the conversion annotation. * @param attributeName the attribute name of the field to coerce. * @param attributeValue the value to coerce. * @return the coerced value.// w w w . j av a2s .co m */ private static Object coerceConverterValue(Convert convert, String attributeName, String attributeValue) { try { AttributeConverter<Object, String> converter = (AttributeConverter<Object, String>) convert.converter() .newInstance(); Object entityAttribute = converter.convertToEntityAttribute(attributeValue); return converter.convertToDatabaseColumn(entityAttribute); } catch (Exception e) { LOG.error("Could not create the converter for " + attributeName, e); } return attributeValue; }