Allow `DbRefResolver` to resolve bulk entities
Opened this issue · 0 comments
It is relatively easy to override DbRefResolver.resolveDbRef() to return a single cached entity object
But if you want to handle the case where the property is a collection of DbRefs it is impossible. The method has no access to the list of DbRef values.
While you can override the bulkFetch() method this returns a list of Document objects - not useful if your cache contains the deserialized objects.
Currently the only solution is to extensively override the MappingMongoConverter. Since many of the methods in this class are private or package scope this requires a lot of code which will likely break with future updates.
Please add a new bulkResolveDbRef() method to DbRefResolver and call this from either MongoMappingConverter.bulkReadAndConvertDBRefs() (before bulkReadRefs()) or MappingMongoConverter.readAssociation() and passing in the full list of DbRefs to give the DbRefResolver a chance to retrieve cached entities.
Ideally DbRefResolver could return a partial list or map DbRef -> Object and MongoMappingConverter could fetch the remaining.