com.mantledillusion.metrics.trail.UUIDStringAttributeConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of trail-metrics-adaptor-jpa Show documentation
Show all versions of trail-metrics-adaptor-jpa Show documentation
JPA based database adaptor for the trail-metrics-api.
The newest version!
package com.mantledillusion.metrics.trail;
import javax.persistence.AttributeConverter;
import java.util.UUID;
/**
* JPA {@link AttributeConverter} to convert a {@link UUID} to {@link String} and vice versa.
*/
public class UUIDStringAttributeConverter implements AttributeConverter {
@Override
public String convertToDatabaseColumn(UUID attribute) {
return attribute.toString();
}
@Override
public UUID convertToEntityAttribute(String dbData) {
return UUID.fromString(dbData);
}
}