I have a class X persisted with hibernate which contains a "strategy" - for which there are three or four concrete implementations. Each is also persisted by hibernate (using joined-subclass).
Now, the strategy should live only as part of X.
We cant seem to be able to work out which type of mapping between X and its strategy to use (or if its even possible at all) such that if we set a new strategy on X, its old strategy is automatically deleted.
At the moment we are having to explicitly cater for a change, and manually delete the previously referenced object.
Could anyone shed any light on whether what we are trying to do is possible - and if so give any tips on how we could go about it?
Cheers,
Dave
|