public class MongoDatabaseUtils extends Object
MongoDatabase instances via MongoDatabaseFactory. Used for obtaining
session bound resources, such as MongoDatabase and
MongoCollection suitable for transactional usage.
| Constructor and Description |
|---|
MongoDatabaseUtils() |
| Modifier and Type | Method and Description |
|---|---|
static com.mongodb.client.MongoDatabase |
getDatabase(MongoDatabaseFactory factory)
|
static com.mongodb.client.MongoDatabase |
getDatabase(MongoDatabaseFactory factory,
SessionSynchronization sessionSynchronization)
Obtain the default
database form the given factory. |
static com.mongodb.client.MongoDatabase |
getDatabase(String dbName,
MongoDatabaseFactory factory)
|
static com.mongodb.client.MongoDatabase |
getDatabase(String dbName,
MongoDatabaseFactory factory,
SessionSynchronization sessionSynchronization)
Obtain the
database with given name form the given factory. |
static boolean |
isTransactionActive(MongoDatabaseFactory dbFactory)
Check if the
MongoDatabaseFactory is actually bound to a ClientSession that has an active
transaction, or if a TransactionSynchronization has been registered for the resource and if the associated ClientSession has an active
transaction. |
public static com.mongodb.client.MongoDatabase getDatabase(MongoDatabaseFactory factory)
database form the given factory using
native session synchronization.
MongoDB specific transaction synchronization within the current
Thread if synchronization is active.factory - the MongoDatabaseFactory to get the MongoDatabase from.MongoDatabase that is potentially associated with a transactional ClientSession.public static com.mongodb.client.MongoDatabase getDatabase(MongoDatabaseFactory factory, SessionSynchronization sessionSynchronization)
database form the given factory.
MongoDB specific transaction synchronization within the current
Thread if synchronization is active.factory - the MongoDatabaseFactory to get the MongoDatabase from.sessionSynchronization - the synchronization to use. Must not be null.MongoDatabase that is potentially associated with a transactional ClientSession.public static com.mongodb.client.MongoDatabase getDatabase(@Nullable String dbName, MongoDatabaseFactory factory)
database with given name form the given factory using
native session synchronization.
MongoDB specific transaction synchronization within the current
Thread if synchronization is active.dbName - the name of the MongoDatabase to get.factory - the MongoDatabaseFactory to get the MongoDatabase from.MongoDatabase that is potentially associated with a transactional ClientSession.public static com.mongodb.client.MongoDatabase getDatabase(@Nullable String dbName, MongoDatabaseFactory factory, SessionSynchronization sessionSynchronization)
database with given name form the given factory.
MongoDB specific transaction synchronization within the current
Thread if synchronization is active.dbName - the name of the MongoDatabase to get.factory - the MongoDatabaseFactory to get the MongoDatabase from.sessionSynchronization - the synchronization to use. Must not be null.MongoDatabase that is potentially associated with a transactional ClientSession.public static boolean isTransactionActive(MongoDatabaseFactory dbFactory)
MongoDatabaseFactory is actually bound to a ClientSession that has an active
transaction, or if a TransactionSynchronization has been registered for the resource and if the associated ClientSession has an active
transaction.dbFactory - the resource to check transactions for. Must not be null.Copyright © 2011–2023 Pivotal Software, Inc.. All rights reserved.