-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: How to copy hibernate objects?
PostPosted: Sun Feb 22, 2004 6:31 am 
Newbie

Joined: Fri Nov 21, 2003 2:20 am
Posts: 5
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.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 22, 2004 8:00 am 
Senior
Senior

Joined: Tue Oct 21, 2003 8:15 am
Posts: 186
Use the metadata api and copy using reflection. Or just write a customer serializer.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.