Code example for HibernateException

0
    public static final char NOT_NULL_PREFIX = '_';
 
    @Override 
    public String fromNonNullValue(String s) {
        if (s.charAt(0) != NOT_NULL_PREFIX) {
            throw new HibernateException("Persistent storage of " + this.getClass().getName() + " corrupted, database contained string [" + s + "] which should be prefixed by: " + NOT_NULL_PREFIX);
        } 
 
        return s.substring(1);
    } 
 
    @Override 
    public String toNonNullValue(String value) {
        return NOT_NULL_PREFIX + value;
    } 
}