Paul Speed - 2007-06-05

Logged In: YES
user_id=652870
Originator: NO

Just some general notes after investigating this a bit... it is a non-trivial operation.

Issue 1: properly detecting all nested meta-objects is tricky at best. The best we could do would be to handle the obvious cases: direct references and collections.

Issue 2: Since clone delegates to copy, we'd need an alternate copy method that knows the destination objects need to be created. In other words, any nested meta-objects need to be cloned instead of having their values copied directly.

Also, internally we'd need a Map to track which objects we'd already cloned.

Deep cloning is a problem that is hard to solve even in Java objects and the sure-fire way is usually to resort to serialization. In that spirit, it may in fact be easier to just create a deep clone method that uses serialization to do the job... then we'd get a chance to recreate every meta-object encountered and convert them to a different MetaKit.

Note: the fact that hibernate currently only supports MapMetaObjects is a separate issue and one I'd like to fix if we can at some point.