The application that we are implementing is using Hibernate 2.12. I am supposed to copy an existing Hibernate entity and do a little changes to it while still keeping the old entity as it is. Now this seems to be a trickier task than I thought. So I desided to ask if there is any easy or even suggested way to do it. I think the question is not so entity specific that mappings are needed this time.
The main problem is that the entity to be copied is a quite complex one and contains many other Hibenate entities and those should be copied also. Of course not the hole database should not be copied. Like if I was copying a car, I would like to copy the tires and the engine, but not the carage. To get this more difficult, we are using composite IDs in some of the entities, I already know this was a bad idea, but there is no turning back at this point. So it seems that the copied main entity must be saved first and the sub entities with composite IDs should be saved later, or is there some other way to do it? And when I need to copy sets inside the entity, how do I do that?
In general, if I implement a clone method to a Hibernate entity, what it should or should not do?
Thanks in advance.
|