Error restoring child DataContext from serialization?

From: Mike Kienenberger (mkienen..mail.com)
Date: Mon May 22 2006 - 19:08:06 EDT

  • Next message: Mike Kienenberger: "Fwd: "Cannot commit changes - channel is not set." after regular DataContext serialization"

    It doesn't look like child DataContexts properly restore from serialization.
    They end up in a state without an EntityResolver because channel is
    non-null and lazyInitParentDomainName is null.

    Before serialization:
    ===========================
    channel= DataContext (id=4110)
    entityResolver= EntityResolver (id=89)
    lazyInitParentDomainName= null
    mergeHandler= DataContextMergeHandler (id=4111)
    objectStore= ObjectStore (id=4112)
    ===========================

    After serialization:
    ===========================
    channel= DataContext (id=4162)
    entityResolver= null
    lazyInitParentDomainName= null
    mergeHandler= null
    objectStore= ObjectStore (id=4163)
    ===========================

        public EntityResolver getEntityResolver() {
            awakeFromDeserialization();
            return entityResolver;
        }

        // Re-attaches itself to the parent domain with previously stored name.
        //
        // TODO: Andrus 11/7/2005 - this is one of the places where Cayenne
        // serialization relies on shared config... This is bad. We need some
        // sort of thread-local solution that would allow to use an
    alternative configuration.
        //
        private final void awakeFromDeserialization() {
            if (channel == null && lazyInitParentDomainName != null) {

                // call a setter to ensure EntityResolver is extracted from channel
                setChannel(Configuration.getSharedConfiguration().getDomain(
                        lazyInitParentDomainName));
            }
        }



    This archive was generated by hypermail 2.0.0 : Mon May 22 2006 - 19:08:33 EDT