max wrote:
sorry - can't see how you would do that in a safe manner - how would you ensure integrity for assocations to those objects ? The original object hibernate has recevied won't be updated when you change the "derived" one you create!
Seriously you need the discriminator ... how do *you* decide which Outer that get's to be an inner ?
If you have some magic for that why don't you just do the conversion from Inner to Outer when you need to save ? (note: this is said very ironically because it will be equally bad integrity-wise)
Let me first thank you for the continued promptness of your responses. I know it is easy to loose interest, especially from all accounts I am not doing the "right thing".
I am afraid I might have confused you with the terms. The Outer is always Outer. There are several Inner* types, which all extend Inner. For these Inner* types, only the fieds that are inherited from the superclass Inner need to be persisted.
Actually the conversion that you ironically refer to is the very approach I have been considering: in method getInner1AsInner construct an Inner and return it (to Hibernate) for persisting and during retrieval when Hibernate calls setInner1AsInner construct an Inner1 from the passed parameter and assign it to the field.