This week's book giveaway is in the Agile and Other Processes forum. We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line! See this thread for details.
I have a Page value object, which consists of several Samples value objects (one to many relationship).
When I try to save a fresh Page (along with one or more samples) here's the approach I follow: 1. Assign temporary ID to the page and each of its samples. 2. Convert the client-value object to its corresponding model value object. 3. Set the relationship within the value objects. 4. Invoke save on the Page, which will also save all the samples within.
So far things are working fine; the save operation functions smoothly and the inserts occur as expected.
Now, I need to assign the newly generated ID's for the page and the samples in the client-side value objects.
The problem here is that since the entire insert (for the page and all its samples) occurs at a go, I am at a loss to keep track as to which of the newly generated ID goes where. The temporary ID's seem to lose their significance given that I am not going and saving each sample individually.
Had I been saving each of the samples in, say, a for-loop it would have been easy for me to map the temporary Id with the corresponding newly-generated ID. But wouldn't this be bad design?