Interface DbRefResolver
- All Superinterfaces:
ReferenceResolver
- All Known Implementing Classes:
DefaultDbRefResolver
,NoOpDbRefResolver
Used to resolve associations annotated with
DBRef
.- Since:
- 1.4
- Author:
- Thomas Darimont, Oliver Gierke, Christoph Strobl, Mark Paluch
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.data.mongodb.core.convert.ReferenceResolver
ReferenceResolver.MongoEntityReader, ReferenceResolver.ReferenceCollection
-
Method Summary
Modifier and TypeMethodDescriptionList<org.bson.Document>
Loads a givenList
ofDBRef
s from the datasource in one batch.default com.mongodb.DBRef
createDbRef
(DBRef annotation, MongoPersistentEntity<?> entity, Object id) org.bson.Document
fetch
(com.mongodb.DBRef dbRef) Actually loads theDBRef
from the datasource.resolveDbRef
(MongoPersistentProperty property, com.mongodb.DBRef dbref, DbRefResolverCallback callback, DbRefProxyHandler proxyHandler) Resolves the givenDBRef
into an object of the givenMongoPersistentProperty
's type.Methods inherited from interface org.springframework.data.mongodb.core.convert.ReferenceResolver
resolveReference
-
Method Details
-
resolveDbRef
@Nullable Object resolveDbRef(MongoPersistentProperty property, @Nullable com.mongodb.DBRef dbref, DbRefResolverCallback callback, DbRefProxyHandler proxyHandler) Resolves the givenDBRef
into an object of the givenMongoPersistentProperty
's type. The method might return a proxy object for theDBRef
or resolve it immediately. In both cases theDbRefResolverCallback
will be used to obtain the actual backing object.- Parameters:
property
- will never be null.dbref
- theDBRef
to resolve.callback
- will never be null.- Returns:
- can be null.
-
createDbRef
default com.mongodb.DBRef createDbRef(@Nullable DBRef annotation, MongoPersistentEntity<?> entity, Object id) - Parameters:
annotation
- will never be null.entity
- will never be null.id
- will never be null.- Returns:
- new instance of
DBRef
.
-
fetch
Actually loads theDBRef
from the datasource.- Parameters:
dbRef
- must not be null.- Returns:
- can be null.
- Since:
- 1.7
-
bulkFetch
Loads a givenList
ofDBRef
s from the datasource in one batch. The resultingList
ofDocument
will reflect the ordering of theDBRef
passed in.
TheDBRef
elements in the list must not reference different collections.- Parameters:
dbRefs
- must not be null.- Returns:
- never null.
- Throws:
InvalidDataAccessApiUsageException
- in case not allDBRef
target the same collection.- Since:
- 1.10
-