|
|
|
@ -19,6 +19,7 @@ import static org.springframework.data.mongodb.core.convert.ReferenceLookupDeleg |
|
|
|
|
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Collections; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.bson.Document; |
|
|
|
import org.springframework.dao.support.PersistenceExceptionTranslator; |
|
|
|
import org.springframework.dao.support.PersistenceExceptionTranslator; |
|
|
|
import org.springframework.data.mongodb.core.mapping.DBRef; |
|
|
|
import org.springframework.data.mongodb.core.mapping.DBRef; |
|
|
|
import org.springframework.data.mongodb.core.mapping.DocumentReference; |
|
|
|
import org.springframework.data.mongodb.core.mapping.DocumentReference; |
|
|
|
@ -32,6 +33,7 @@ import org.springframework.util.Assert; |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Christoph Strobl |
|
|
|
* @author Christoph Strobl |
|
|
|
* @author Mark Paluch |
|
|
|
* @author Mark Paluch |
|
|
|
|
|
|
|
* @author Anton Buzdalkin |
|
|
|
* @since 3.3 |
|
|
|
* @since 3.3 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class DefaultReferenceResolver implements ReferenceResolver { |
|
|
|
public class DefaultReferenceResolver implements ReferenceResolver { |
|
|
|
@ -41,8 +43,8 @@ public class DefaultReferenceResolver implements ReferenceResolver { |
|
|
|
|
|
|
|
|
|
|
|
private final LookupFunction collectionLookupFunction = (filter, ctx) -> getReferenceLoader().fetchMany(filter, ctx); |
|
|
|
private final LookupFunction collectionLookupFunction = (filter, ctx) -> getReferenceLoader().fetchMany(filter, ctx); |
|
|
|
private final LookupFunction singleValueLookupFunction = (filter, ctx) -> { |
|
|
|
private final LookupFunction singleValueLookupFunction = (filter, ctx) -> { |
|
|
|
Object target = getReferenceLoader().fetchOne(filter, ctx); |
|
|
|
Document target = getReferenceLoader().fetchOne(filter, ctx); |
|
|
|
return target == null ? Collections.emptyList() : Collections.singleton(getReferenceLoader().fetchOne(filter, ctx)); |
|
|
|
return target == null ? Collections.emptyList() : Collections.singleton(target); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|