baliukas wrote:
Use "discriminator" as usual property in domain model. If you need to change "discriminator" then it meens there is no inheritance in domain model, drop it.
Impossible, every class has distinct behaviour and extra fields compared
to the abstract base class.
Look, when a user asks to change the type of an "activity" in my user interface, I just keep the common fields between the two subclasses, and ask the user to fill in the missing fields before finishing the conversion in the user interface.
Anyway, I've changed the code to "update" the database with the changed class, flush the session, and then perform a discriminator change by hand using a query. Works fine.
It seems to me that you've decided it does not make sense to change an object class and thus do not support it, but it would be tecnically feasible.
I've also asked my colleagues, one has already stumped in this problem and found another workaround (it was a simpler case), but he also needed to change the class of a persistent object, that is, it was the logical thing to do.
Mine or his workaround are just tricks, they don't match the logic of what we're doing...