michael wrote:
Hibernate does not do anything you can't do in your java object model. Objects just don't suddenly change their type in java, and its just the same in Hibernate. I suggest you change your class model. This has been discussed in a lengthy thread sometime ago, search for it if you want more info.
I hear what you're saying, but it's not really a fair point since the Object and relational worlds have different limitations, and therefore need to different features in order to achieve the same functionality.
Namely, in the object world if I have B as sublcass of A, I can make a new instance of B, that has the same ID property as some existingin instance of A.
In the relational world, I simply can't add a new row to a table that has the same ID as an existing row, so I have to delete the "instance" of A before I can create a new instance of "B". This is why you need to be able to "change types" in the relational world, even though you can't do it in Java.