There is an annotation in Hibernate that can persist boolean types as \'Y\'/\'N\' in the database.
https://stackoverflow.com/questions/1154833/configure-hibernate-u
This is pure JPA without using getters/setters, so it answers the question:
@Entity
public class Person {
@Convert(converter=BooleanToStringConverter.class)
private Boolean isAlive;
...
}
And then:
@Converter
public class BooleanToStringConverter implements AttributeConverter {
@Override
public String convertToDatabaseColumn(Boolean value) {
return (value == null || !value) ? "N" : "Y";
}
@Override
public Boolean convertToEntityAttribute(String value) {
return "Y".equals(value);
}
}
Please note this solution is JPA 2.1, and was not available when the question was first asked: The JPA 2.1 specification was released 22 April 2013.