Hello.
When using the inheritance mapping strategy 'table per class hierarchy', one has to specify the discriminator column and its value for every concrete class to be mapped.
I wonder whether it's possible to map such case without using a discriminator column. I mean, one can see it in a more general way: we have the values read from the DB and we now have to decide which class must be instantiated. Discriminator column is one way to do this, it uses the value of the specified column to derive the class. Is it possible to specify a custom 'resolver' for this?
My case is that in my table, I have two columns of which exactly one is not NULL. Depending on which one is not NULL, the one or the other class should be instantiated. Can I achieve this without introducing the discriminator column? I could provide a custom 'discriminator' that would look at these two columns and tell which class should be instantiated. Further field filling goes the usual hibernate way. Is it possible to hook such a discriminator and how?
Any help is much appreciated.
|