목차

JPA Converter

@Converter
public class PersonNameConverter implements AttributeConverter<PersonName, String> {
 
    @Override
    public String convertToDatabaseColumn(PersonName personName) {
        // object to DB column 구현
    }
 
    @Override
    public PersonName convertToEntityAttribute(String dbPersonName) {
       // DB column to object 구현
}
 
@Entity(name = "PersonTable")
public class Person {
 
    @Convert(converter = PersonNameConverter.class)
    private PersonName personName;
 
    // ...
}

변환 클래스에 equals & hashCode 구현 필수

잘못된 Colum Type 매핑

@Convert(converter=ISBNConverter.class)
@org.hibernate.annotations.Type(type="string")
private ISBN isbn;