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 DBRefs 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
  • Constructor Details

  • Method Details

    • resolveDbRef

      public Object resolveDbRef(MongoPersistentProperty property, @Nullable com.mongodb.DBRef dbref, DbRefResolverCallback callback, DbRefProxyHandler handler)
      Description copied from interface: DbRefResolver
      Resolves the given DBRef into an object of the given MongoPersistentProperty's type. The method might return a proxy object for the DBRef or resolve it immediately. In both cases the DbRefResolverCallback will be used to obtain the actual backing object.
      Specified by:
      resolveDbRef in interface DbRefResolver
      Parameters:
      property - will never be null.
      dbref - the DBRef 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 the DBRef from the datasource.
      Specified by:
      fetch in interface DbRefResolver
      Parameters:
      dbRef - must not be null.
      Returns:
      can be null.
    • bulkFetch

      public List<org.bson.Document> bulkFetch(List<com.mongodb.DBRef> refs)
      Description copied from interface: DbRefResolver
      Loads a given List of DBRefs from the datasource in one batch. The resulting List of Document will reflect the ordering of the DBRef passed in.
      The DBRef elements in the list must not reference different collections.
      Specified by:
      bulkFetch in interface DbRefResolver
      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 the MongoCollection for a given DBRef.
      Parameters:
      dbref - must not be null.
      Returns:
      the MongoCollection the given DBRef points to.
      Since:
      2.1
    • getCollection

      protected com.mongodb.client.MongoCollection<org.bson.Document> getCollection(ReferenceResolver.ReferenceCollection context)