Skip to content

Fix #5346: Add MongoDatabaseFactory support to MongoJobRepositoryFactoryBean#5352

Open
nikitanagar08 wants to merge 1 commit intospring-projects:mainfrom
nikitanagar08:fix-5346-mongodb-mapkeydotreplacement-clean
Open

Fix #5346: Add MongoDatabaseFactory support to MongoJobRepositoryFactoryBean#5352
nikitanagar08 wants to merge 1 commit intospring-projects:mainfrom
nikitanagar08:fix-5346-mongodb-mapkeydotreplacement-clean

Conversation

@nikitanagar08
Copy link
Copy Markdown

@nikitanagar08 nikitanagar08 commented Mar 20, 2026

This PR addresses #5346 by adding support for MongoDatabaseFactory in MongoJobRepositoryFactoryBean and MongoJobExplorerFactoryBean.

Problem

Users had to create a separate MongoTemplate with MapKeyDotReplacement configuration specifically for Spring Batch, which was cumbersome.

Solution

  • Added setMongoDatabaseFactory() method to accept a MongoDatabaseFactory
  • The factory now creates the required MongoTemplate internally with proper MapKeyDotReplacement configuration
  • Deprecated setMongoOperations() in favor of the new approach
  • Applied the same changes to MongoJobExplorerFactoryBean

Benefits

  • Users can now simply provide a MongoDatabaseFactory instead of creating a separate MongoTemplate
  • The required MapKeyDotReplacement configuration is handled automatically
  • Backward compatibility is maintained with the deprecated setMongoOperations() method

@nikitanagar08 nikitanagar08 force-pushed the fix-5346-mongodb-mapkeydotreplacement-clean branch from c19ea1d to 3516d11 Compare March 20, 2026 16:06
…bRepositoryFactoryBean

This commit addresses the issue where users had to create a separate
MongoTemplate with MapKeyDotReplacement configuration specifically for
Spring Batch.

Changes:
- Add setMongoDatabaseFactory() method to MongoJobRepositoryFactoryBean
- Deprecate setMongoOperations() in favor of setMongoDatabaseFactory()
- Create MongoTemplate internally with required MapKeyDotReplacement config
- Update MongoJobExplorerFactoryBean with the same changes

This allows users to simply provide a MongoDatabaseFactory instead of
creating a separate MongoTemplate for Spring Batch.

Signed-off-by: Nikita Nagar <permanayan84@gmail.com>
@nikitanagar08 nikitanagar08 force-pushed the fix-5346-mongodb-mapkeydotreplacement-clean branch from 3516d11 to 0e1b887 Compare March 20, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant