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.  [ 5 posts ] 
Author Message
 Post subject: Cloneing objects for manual timestamp-like functionality
PostPosted: Tue Sep 02, 2003 11:51 am 
Beginner
Beginner

Joined: Wed Aug 27, 2003 7:53 am
Posts: 27
Hi,

I'd like to ask whether it's possible to 'clone' an object (or rather a graph of hibernated objects) and persist them as new ones, keeping all existing properties, and updating all associations to use the 'cloned' references to objects... I'd need that badly to add timestamp-like functionality (I've checked the hibernate timestamps briefly, but I'd need more than that).

Plain Old Example:
Code:
entity Person : id, name, city_id, timestamp
entity City: id, name


Sample data:
Code:
Person (1, "Foo", 1, 13897636)
Person (2, "Bar", 1, 13967190)
City (1, "New York", 97390713)


Data I'd need to get after the cloning (somehow):
Code:
Person (3, "Foo", 2, 13897636)
Person (4, "Bar", 2, 13967190)
City (2, "New York", 97390713)


..and then I'd update the 'timestamps' myself before persisting these objects..

Is there any way to achieve such functionality? If I need to take the hard, manual way, what would be the less painful way to updates all the associations as well beside cloning the objects?

thanks much,
dyn

_________________
.Digital.Yearning.for.Networked.Assassination.and.Xenocide


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 02, 2003 6:22 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You can use the Hibernate metadata API to implement deepcopy algorithms. I've no idea whats wrong with Hibernate's auto-timstamping though.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 02, 2003 6:23 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Oh, also, other people use Interceptor for this kind of thing.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 03, 2003 2:52 am 
Beginner
Beginner

Joined: Wed Aug 27, 2003 7:53 am
Posts: 27
I'm not 100% sure hibernate's timestamping won't be enough, I only think so. Let me explain briefly what I'd need:

I have to store versioned entities, a whole graph of them for every month ('timestamp' would be YYYY-mm therefore). I must be able to load entities for a specified year/month (this date can be in the future as well), and update them without changing the timestamp. Possible missions include loading all entities for 2003 september, updating them, and save back with the same year/month (normal behaviour); or loading all entities for 2003 september, updating all of them for 2003 october, and commit back (preparing next month data). Is that possible with Hibernate's versioning?

I'll investigate the metadata and the Interceptor approach for my needs meanwhile.

Thanks.
dyn

_________________
.Digital.Yearning.for.Networked.Assassination.and.Xenocide


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 14, 2005 3:36 pm 
Newbie

Joined: Wed Jan 26, 2005 3:04 am
Posts: 3
Would the little know replicate() method be a solution to this problem?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.