Q:

How to use Spring/Hibernate validation on a char field?

I would like to use validation on a Character field which should have either a 'Y' or 'N' in it.  I checked for existing answers such as this one, but the most common answer seems to be "change the Character to a String and use @Pattern" which I can't do in this case.
Is there an existing validation annotation available for Character values?   I can't seem to find one.  How does one validate a Character field?

A:

You can use the yes_no type in hibernate.
mapping:
<property name="flagField" type="yes_no"/>

or
@Type(type="yes_no")
public boolean getFlagField();

This will appear as Y/N in the database.
Useful link: http://www.concretepage.com/hibernate/type_yesno_hibernate_annotation

