Class DefaultDbRefResolver
java.lang.Object
org.springframework.data.mongodb.core.convert.DefaultReferenceResolver
org.springframework.data.mongodb.core.convert.DefaultDbRefResolver
- All Implemented Interfaces:
DbRefResolver
,ReferenceResolver
public class DefaultDbRefResolver
extends DefaultReferenceResolver
implements DbRefResolver, ReferenceResolver
A
DbRefResolver
that resolves DBRef
s by delegating to a
DbRefResolverCallback
than is able to generate lazy loading proxies.- 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
-
Constructor Summary
ConstructorDescriptionDefaultDbRefResolver
(MongoDatabaseFactory mongoDbFactory) Creates a newDefaultDbRefResolver
with the givenMongoDatabaseFactory
. -
Method Summary
Modifier and TypeMethodDescriptionList<org.bson.Document>
Loads a givenList
ofDBRef
s from the datasource in one batch.org.bson.Document
fetch
(com.mongodb.DBRef dbRef) Actually loads theDBRef
from the datasource.protected com.mongodb.client.MongoCollection<org.bson.Document>
getCollection
(com.mongodb.DBRef dbref) Customization hook for obtaining theMongoCollection
for a givenDBRef
.protected com.mongodb.client.MongoCollection<org.bson.Document>
resolveDbRef
(MongoPersistentProperty property, com.mongodb.DBRef dbref, DbRefResolverCallback callback, DbRefProxyHandler handler) Resolves the givenDBRef
into an object of the givenMongoPersistentProperty
's type.Methods inherited from class org.springframework.data.mongodb.core.convert.DefaultReferenceResolver
getReferenceLoader, isLazyReference, resolveReference
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.data.mongodb.core.convert.DbRefResolver
createDbRef
Methods inherited from interface org.springframework.data.mongodb.core.convert.ReferenceResolver
resolveReference
-
Constructor Details
-
DefaultDbRefResolver
Creates a newDefaultDbRefResolver
with the givenMongoDatabaseFactory
.- Parameters:
mongoDbFactory
- must not be null.
-
-
Method Details
-
resolveDbRef
public Object resolveDbRef(MongoPersistentProperty property, @Nullable com.mongodb.DBRef dbref, DbRefResolverCallback callback, DbRefProxyHandler handler) Description copied from interface:DbRefResolver
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.- Specified by:
resolveDbRef
in interfaceDbRefResolver
- Parameters:
property
- will never be null.dbref
- theDBRef
to resolve.callback
- will never be null.- Returns:
- can be null.
-
fetch
public org.bson.Document fetch(com.mongodb.DBRef dbRef) Description copied from interface:DbRefResolver
Actually loads theDBRef
from the datasource.- Specified by:
fetch
in interfaceDbRefResolver
- Parameters:
dbRef
- must not be null.- Returns:
- can be null.
-
bulkFetch
Description copied from interface:DbRefResolver
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.- Specified by:
bulkFetch
in interfaceDbRefResolver
- Parameters:
refs
- must not be null.- Returns:
- never null.
-
getCollection
protected com.mongodb.client.MongoCollection<org.bson.Document> getCollection(com.mongodb.DBRef dbref) Customization hook for obtaining theMongoCollection
for a givenDBRef
.- Parameters:
dbref
- must not be null.- Returns:
- the
MongoCollection
the givenDBRef
points to. - Since:
- 2.1
-
getCollection
protected com.mongodb.client.MongoCollection<org.bson.Document> getCollection(ReferenceResolver.ReferenceCollection context)
-