Helper class for managing a MongoDatabase instances via MongoDbFactory. Used for obtaining
session bound resources, such as MongoDatabase and
MongoCollection suitable for transactional usage.
Note: Intended for internal usage only.
Obtain the default database form the given factory.
Registers a MongoDB specific transaction synchronization within the current
Thread if synchronization is active.
Parameters:
factory - the MongoDbFactory to get the MongoDatabase from.
sessionSynchronization - the synchronization to use. Must not be null.
Returns:
the MongoDatabase that is potentially associated with a transactional ClientSession.
getDatabase
public static com.mongodb.client.MongoDatabase getDatabase(String dbName,
MongoDbFactory factory)
Obtain the database with given name form the given factory.
Registers a MongoDB specific transaction synchronization within the current
Thread if synchronization is active.
Parameters:
dbName - the name of the MongoDatabase to get.
factory - the MongoDbFactory to get the MongoDatabase from.
sessionSynchronization - the synchronization to use. Must not be null.
Returns:
the MongoDatabase that is potentially associated with a transactional ClientSession.