Package com.github.jmkgreen.morphia.mapping.lazy.proxy

Examples of com.github.jmkgreen.morphia.mapping.lazy.proxy.ProxiedEntityReferenceList


    private void writeCollection(MappedField mf, DBObject dbObject, String name, Object fieldValue, Mapper mapr) {
        if (fieldValue != null) {
            List values = new ArrayList();

            if (ProxyHelper.isProxy(fieldValue) && ProxyHelper.isUnFetched(fieldValue)) {
                ProxiedEntityReferenceList p = (ProxiedEntityReferenceList) fieldValue;
                List<Key<?>> getKeysAsList = p.__getKeysAsList();
                for (Key<?> key : getKeysAsList) {
                    addValue(values, key, mapr);
                }
            } else {
View Full Code Here


        if (refAnn.lazy() && LazyFeatureDependencies.assertDependencyFullFilled()) {
            Object dbVal = mf.getDbObjectValue(dbObject);
            if (dbVal != null) {
                references = mapr.getProxyFactory().createListProxy(references, referenceObjClass, refAnn.ignoreMissing(),
                        mapr.getDatastoreProvider());
                ProxiedEntityReferenceList referencesAsProxy = (ProxiedEntityReferenceList) references;

                if (dbVal instanceof List) {
                    List<DBRef> refList = (List) dbVal;
                    Datastore dsi = mapr.getDatastoreProvider().get();
                    List<Key<Object>> keys = dsi.getKeysByRefs(refList);

                    if (keys.size() != refList.size()) {
                        String msg = "Some of the references could not be fetched for " + mf.getFullName() + ". "
                                + refList + " != " + keys;
                        if (!refAnn.ignoreMissing())
                            throw new MappingException(msg);
                        else
                            log.warning(msg);
                    }

                    referencesAsProxy.__addAll(keys);
                } else {
                    DBRef dbRef = (DBRef) dbVal;
                    if (!exists(mf.getSubClass(), dbRef, cache, mapr)) {
                        String msg = "The reference(" + dbRef.toString() + ") could not be fetched for "
                                + mf.getFullName();
                        if (!refAnn.ignoreMissing())
                            throw new MappingException(msg);
                        else
                            log.warning(msg);
                    } else {
                        referencesAsProxy.__add(mapr.refToKey(dbRef));
                    }
                }
            }
        } else {
            Object dbVal = mf.getDbObjectValue(dbObject);
View Full Code Here

TOP

Related Classes of com.github.jmkgreen.morphia.mapping.lazy.proxy.ProxiedEntityReferenceList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.