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.  [ 4 posts ] 
Author Message
 Post subject: Persisting a collection of objects
PostPosted: Mon Jun 18, 2007 12:16 am 
Beginner
Beginner

Joined: Mon May 07, 2007 11:12 pm
Posts: 20
Hello,

I have a collection of objects that I need to persist. Each object may be in a different state - ie .some new, some updated and need to be persisted and some that need to be deleted.

This collection is not part of another object. Is there a recommended way to do this in Hibernate? I can add my own way to maintain state, but it seems as though hibernate has this capability and I would like some guidance on the best way.

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 18, 2007 12:26 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Hi suneetshah,

Best way to do is use child parent association. and collection of object should be in child and use cascade="all" .And for persist these use session.saveOrUpdate(parent). This would automatically save or update according to given ID and unsaved value.

If you don’t have these association then it is tuff fight. You need to persist one by one with session.saveOrUpdate (ID logic would be same).Otherwise you could go for hibenateTemplate but again it is not recommended.


Note Hibernate works excellent when object modeling is perfect

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 18, 2007 12:31 am 
Beginner
Beginner

Joined: Mon May 07, 2007 11:12 pm
Posts: 20
Hi dharmendra,

The challenge here is that I dont have a parent-child association. Its a collection of simple objects.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 18, 2007 12:46 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Go for second one

_________________
Dharmendra Pandey


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