When I have an optional foreign key relationships eg Customer has Timezone, then if a customer does not have a timezone, it gets stored on the DB as a padded empty string (ie it is Never null). In the O/R tool I use at the moment (jaxor) I map this onto a Timezone.NULL_CODE. Every customer therefore has a non-null Timezone.
I'm now plugging-in Hibernate in place or jaxor and wonder how to achieve the above.
many-to-one doesn't work because it tries to lookup the blank Timezone and of course throws UnresolvableObjectException.
Is my only option a UserType, where I test for blanks, and perform the lookup myself?
|