Interface DbRefResolver

All Superinterfaces:
ReferenceResolver
All Known Implementing Classes:
DefaultDbRefResolver, NoOpDbRefResolver

public interface DbRefResolver extends ReferenceResolver
Used to resolve associations annotated with DBRef.
Since:
1.4
Author:
Thomas Darimont, Oliver Gierke, Christoph Strobl, Mark Paluch
  • Method Details

    • resolveDbRef

      @Nullable Object resolveDbRef(MongoPersistentProperty property, @Nullable com.mongodb.DBRef dbref, DbRefResolverCallback callback, DbRefProxyHandler proxyHandler)
      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.
      Parameters:
      property - will never be null.
      dbref - the DBRef to resolve.
      callback - will never be null.
      Returns:
      can be null.
    • createDbRef

      default com.mongodb.DBRef createDbRef(@Nullable DBRef annotation, MongoPersistentEntity<?> entity, Object id)
      Creates a DBRef instance for the given DBRef annotation, MongoPersistentEntity and id.
      Parameters:
      annotation - will never be null.
      entity - will never be null.
      id - will never be null.
      Returns:
      new instance of DBRef.
    • fetch

      @Nullable org.bson.Document fetch(com.mongodb.DBRef dbRef)
      Actually loads the DBRef from the datasource.
      Parameters:
      dbRef - must not be null.
      Returns:
      can be null.
      Since:
      1.7
    • bulkFetch

      List<org.bson.Document> bulkFetch(List<com.mongodb.DBRef> dbRefs)
      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.
      Parameters:
      dbRefs - must not be null.
      Returns:
      never null.
      Throws:
      InvalidDataAccessApiUsageException - in case not all DBRef target the same collection.
      Since:
      1.10