I have a legacy database being replicated to a SQL Server database which stores null values as empty strings, including for foreign key columns. This setup cannot be changed.
I’d like to interpret these empty string values as null. I’ve been able to do this for simple fields using a custom HibernateInterceptor with implemented onLoad method. However, for “@ManyToOne” fields, the interceptor is not fired prior to the relationship being evaluated and an EntityNotFoundException is thrown whenever an optional foreign key is an empty string. I understand this could be ignored with the “@NotFound” annotation, but this is not what I want to do because an extraneous database lookup will be done.
Any ideas?