Module spring.data.mongodb
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 givenListofDBRefs from the datasource in one batch.default com.mongodb.DBRefcreateDbRef(DBRef annotation, MongoPersistentEntity<?> entity, Object id) org.bson.Documentfetch(com.mongodb.DBRef dbRef) Actually loads theDBReffrom the datasource.resolveDbRef(MongoPersistentProperty property, com.mongodb.DBRef dbref, DbRefResolverCallback callback, DbRefProxyHandler proxyHandler) Resolves the givenDBRefinto 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 givenDBRefinto an object of the givenMongoPersistentProperty's type. The method might return a proxy object for theDBRefor resolve it immediately. In both cases theDbRefResolverCallbackwill be used to obtain the actual backing object.- Parameters:
property- will never be null.dbref- theDBRefto 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 theDBReffrom the datasource.- Parameters:
dbRef- must not be null.- Returns:
- can be null.
- Since:
- 1.7
-
bulkFetch
Loads a givenListofDBRefs from the datasource in one batch. The resultingListofDocumentwill reflect the ordering of theDBRefpassed in.
TheDBRefelements in the list must not reference different collections.- Parameters:
dbRefs- must not be null.- Returns:
- never null.
- Throws:
InvalidDataAccessApiUsageException- in case not allDBReftarget the same collection.- Since:
- 1.10
-