I am trying to define a subclass matching a discriminator-value that can be either of 2 possible values, ie. is in ["a", "b"]. Is this possible?
E.g. in the example below, a "sportsfan" can be a "soccerFan", a "tennisFan" or BOTH. I do NOT want to create a separate object "soccerTennisFan" for the latter.
<class name="sportsFan" table="sportsfan"> .. <discriminator column="fanType" type="integer" />
.. <subclass name="soccerFan" discriminator-value="1"> <subclass name="tennisFan" discriminator-value="2">
(The corresponding descriminator value for a fan that belongs to BOTH would be 3.)
I already looked at using a formula in the discriminator, sth. like
<discriminator "case when FAN_TYPE in ("1","3") then "soccerfan" else when FAN_TYPE in ("2","3") then "tennisFan" else "otherFan" />
However, in this case if FAN_TYPE is 3 (ie. soccer AND tennis fan), he would always come out as a soccer fan only.
Another option I see would be using multiple discriminators (e.g. first = "isSoccerFan", second = "isTennisFan"), but I don't think Hibernate supports such.
Any help/ideas appreciated.
|