@Override public Object populateId(MongoPersistentProperty property, @Nullable DBRef source, Object proxy) { if (source == null) { return proxy; } MongoPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(property); MongoPersistentProperty idProperty = entity.getRequiredIdProperty(); if (idProperty.usePropertyAccess()) { return proxy; } SpELExpressionEvaluator evaluator = new DefaultSpELExpressionEvaluator(proxy, spELContext); PersistentPropertyAccessor accessor = entity.getPropertyAccessor(proxy); Document object = new Document(idProperty.getFieldName(), source.getId()); ObjectPath objectPath = ObjectPath.ROOT.push(proxy, entity, null); accessor.setProperty(idProperty, resolver.getValueInternal(idProperty, object, evaluator, objectPath)); return proxy; } }
private <S> S populateProperties(MongoPersistentEntity<S> entity, DocumentAccessor documentAccessor, ObjectPath path, SpELExpressionEvaluator evaluator, S instance) { PersistentPropertyAccessor<S> accessor = new ConvertingPropertyAccessor<>(entity.getPropertyAccessor(instance), conversionService); // Make sure id property is set before all other properties Object rawId = readAndPopulateIdentifier(accessor, documentAccessor, entity, path, evaluator); ObjectPath currentPath = path.push(accessor.getBean(), entity, rawId); MongoDbPropertyValueProvider valueProvider = new MongoDbPropertyValueProvider(documentAccessor, evaluator, currentPath); readProperties(entity, accessor, documentAccessor, valueProvider, currentPath, evaluator); return accessor.getBean(); }
@Override public Object populateId(MongoPersistentProperty property, @Nullable DBRef source, Object proxy) { if (source == null) { return proxy; } MongoPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(property); MongoPersistentProperty idProperty = entity.getRequiredIdProperty(); if (idProperty.usePropertyAccess()) { return proxy; } SpELExpressionEvaluator evaluator = new DefaultSpELExpressionEvaluator(proxy, spELContext); PersistentPropertyAccessor accessor = entity.getPropertyAccessor(proxy); Document object = new Document(idProperty.getFieldName(), source.getId()); ObjectPath objectPath = ObjectPath.ROOT.push(proxy, entity, null); accessor.setProperty(idProperty, resolver.getValueInternal(idProperty, object, evaluator, objectPath)); return proxy; } }
private <S> S populateProperties(MongoPersistentEntity<S> entity, DocumentAccessor documentAccessor, ObjectPath path, SpELExpressionEvaluator evaluator, S instance) { PersistentPropertyAccessor<S> accessor = new ConvertingPropertyAccessor<>(entity.getPropertyAccessor(instance), conversionService); // Make sure id property is set before all other properties Object rawId = readAndPopulateIdentifier(accessor, documentAccessor, entity, path, evaluator); ObjectPath currentPath = path.push(accessor.getBean(), entity, rawId); MongoDbPropertyValueProvider valueProvider = new MongoDbPropertyValueProvider(documentAccessor, evaluator, currentPath); readProperties(entity, accessor, documentAccessor, valueProvider, currentPath, evaluator); return accessor.getBean(); }