Elia Morling <eli..amiljen.se> wrote:
> > Wouldn't such a method create numerous problems with deep and/or shallow
> > copies, and duplication of relationships?
>
> Yes if it has a to-many relationship, but there are plenty of leaves at
the bottom
> of the tree using only parents. Which in many cases will be created and
duplicated
> often.
>
> 1. Validate object to make sure it doesn't have a to-many relationship
> 2. CreateAndRegisterNewObject with the class of the source object
> 3. For each property in source object writeProperty() in new object
> 4. Pass along any exceptions
Sounds like you have it all figured out.
It's probably worth submitting your solution as an enhancement (maybe as a
method on DataContext) as it's been requested before. I use a similar
solution in a WebObjects project that has not yet been ported to Cayenne.
An even more comprehensive solution would allow you to
duplicateAndRegisterNewObjectCollection(Collection ofDataObjects). Any
relationships that exist only between objects in the collection would be
created among the new objects.
-Mike
This archive was generated by hypermail 2.0.0 : Sat Jul 31 2004 - 08:01:26 EDT