-->
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: Removing items from collections in stateless environment
PostPosted: Wed Mar 21, 2007 9:15 pm 
Newbie

Joined: Wed Dec 29, 2004 2:37 am
Posts: 11
I am working on a web project where the user can edit / add and delete items that are stored in a collection in my object. Since this is stateless, the most efficient way I can think of doing this is clearing the collection ( using clear() ), and then re-adding them all.

Under my normal development strategy for this type of issue, it isnt a problem since I use a business key instead of a primary key and the collections are value type collections (ie discardable). I have read that this is a horrible practice, but I can not figure out what the correct way to accomplish this task is. Below is concrete examples of my data structures. Any help or thoughts will be dearly valued.

ResumesTable
pk_resume
resume_text

SkillsTable
resume_id
skill_id
yrs_experience

SkillsListTable
skill_id
skill_category
skill_Name


Top
 Profile  
 
 Post subject: Re: Removing items from collections in stateless environment
PostPosted: Thu Mar 22, 2007 3:15 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
cgamble wrote:
Under my normal development strategy for this type of issue, it isnt a problem since I use a business key instead of a primary key and the collections are value type collections (ie discardable). I have read that this is a horrible practice, but I can not figure out what the correct way to accomplish this task is. Below is concrete examples of my data structures. Any help or thoughts will be dearly valued.

What are you asking is considered "horrible practice"? If you're speaking about using technical/surrogate keys instead of business ones, then yes, it's a best practice.

It's simply because it lets you evolve your schema more easily. Even a business key modification is simpler if you use a surrogate key (you won't have to update every foreign keys on this key, for example...)

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject: Practice
PostPosted: Wed Mar 28, 2007 4:45 pm 
Newbie

Joined: Wed Dec 29, 2004 2:37 am
Posts: 11
I guess my question is more along the lines of: if I remove 10 ids from a web page that is not connected to the objects, is there an easy way without writing the 20's of lines of code to find out what was removed and what was updated. My normal scheme is just to remove everything and re-add them all. Every other table uses an identify field as the primary key, but with the number of deletes and adds that occur here, the identity will be in the millions by the end of the year.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 29, 2007 12:40 am 
Regular
Regular

Joined: Tue Feb 21, 2006 9:50 am
Posts: 107
Quote:
Every other table uses an identify field as the primary key, but with the number of deletes and adds that occur here, the identity will be in the millions by the end of the year.

This is one of the reasons why i prefer GUID's as primary keys. They are unique by default and i don't run in overflow problems. Of course there are disadvantages: The readability is low and GUID's are handled less efficient by the server.

Did you mean that your collections contains just object instances which represents records from a single table? In this case i'm afraid there will be no easy way to find out which objects where removed. In one of my applications i had implemented a solution with two collections (current and deleted). If the user deletes an item it was moved to the 'deleted' collection. The update method iterates through both collections.

Regards
Klaus


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.