class ReferenceAttributeConverter implements AttributeConverter<Reference, String> {

    @Override
    public Reference convertToEntityAttribute( String dbData )
    {
        if ( dbData == null )
        {
            return null;
        }
        final int index = dbData.indexOf( SEPARATOR );

        if ( (index <= 0) || (index + 1 == dbData.length()) )
        {
            throw new IllegalArgumentException( "Reference does not include required separator: " + dbData );
        }

        return new Reference( dbData.substring( index + 1 ), NameUtils.toEnumValue( ReferenceType.class, dbData.substring( 0, index ) ) );
    }

}