public interface MongoDatabaseFactory extends CodecRegistryProvider, MongoSessionProvider
MongoDatabase
instances.Modifier and Type | Method and Description |
---|---|
default org.bson.codecs.configuration.CodecRegistry |
getCodecRegistry()
Get the underlying
CodecRegistry used by the MongoDB Java driver. |
PersistenceExceptionTranslator |
getExceptionTranslator()
Exposes a shared
MongoExceptionTranslator . |
com.mongodb.client.MongoDatabase |
getMongoDatabase()
Obtain a
MongoDatabase from the underlying factory. |
com.mongodb.client.MongoDatabase |
getMongoDatabase(String dbName)
Obtain a
MongoDatabase instance to access the database with the given name. |
com.mongodb.client.ClientSession |
getSession(com.mongodb.ClientSessionOptions options)
Obtain a
ClientSession for given ClientSessionOptions. |
default boolean |
isTransactionActive()
Returns if the given
MongoDatabaseFactory is bound to a ClientSession that has an
active transaction . |
MongoDatabaseFactory |
withSession(com.mongodb.client.ClientSession session)
Obtain a
ClientSession bound instance of MongoDatabaseFactory returning MongoDatabase
instances that are aware and bound to the given session. |
default MongoDatabaseFactory |
withSession(com.mongodb.ClientSessionOptions options)
Obtain a
ClientSession bound instance of MongoDatabaseFactory returning MongoDatabase
instances that are aware and bound to a new session with given options . |
getCodecFor, hasCodecFor
com.mongodb.client.MongoDatabase getMongoDatabase() throws DataAccessException
MongoDatabase
from the underlying factory.DataAccessException
com.mongodb.client.MongoDatabase getMongoDatabase(String dbName) throws DataAccessException
MongoDatabase
instance to access the database with the given name.dbName
- must not be null.DataAccessException
PersistenceExceptionTranslator getExceptionTranslator()
MongoExceptionTranslator
.default org.bson.codecs.configuration.CodecRegistry getCodecRegistry()
CodecRegistry
used by the MongoDB Java driver.getCodecRegistry
in interface CodecRegistryProvider
com.mongodb.client.ClientSession getSession(com.mongodb.ClientSessionOptions options)
ClientSession
for given ClientSessionOptions.getSession
in interface MongoSessionProvider
options
- must not be null.default MongoDatabaseFactory withSession(com.mongodb.ClientSessionOptions options)
ClientSession
bound instance of MongoDatabaseFactory
returning MongoDatabase
instances that are aware and bound to a new session with given options
.options
- must not be null.MongoDatabaseFactory withSession(com.mongodb.client.ClientSession session)
ClientSession
bound instance of MongoDatabaseFactory
returning MongoDatabase
instances that are aware and bound to the given session.session
- must not be null.default boolean isTransactionActive()
MongoDatabaseFactory
is bound to a ClientSession
that has an
active transaction
.Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.