-->
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.  [ 1 post ] 
Author Message
 Post subject: Save/remove children through parrent collection
PostPosted: Thu Aug 05, 2010 7:04 pm 
Newbie

Joined: Wed Aug 04, 2010 5:39 am
Posts: 3
Hi,

i am writing a piece of logic which would save/remove attachments to an action. Frontend displays all possible attachments for this action and then the user has to select which attachment to save with that action. Selected attachments are saved in a different entity.

Upper layer provides me with a map of attachments (Map<Integer, Boolean> -> second parameter mean attachment selected/deselected). I am wondering how would you solve this situation. My procedure is following:

1) If attachmentId from map is selected, iterate through action.getActionAttachments(), and if it does not exist add it to the collection.
2) If attachmentId from map is selected and is found in action.getActionAttachments(), do not make any changes.
3) If attachmentId from map is not selected, find attachment in action.getActionAttachments() and remove it from the set.
4) actionDao.save(action)

Any other better solution/advice greatly appreciated.


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

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.