public interface MongoDbFactory 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. |
com.mongodb.client.MongoDatabase |
getDb()
Creates a default
MongoDatabase instance. |
com.mongodb.client.MongoDatabase |
getDb(String dbName)
Creates a
DB instance to access the database with the given name. |
PersistenceExceptionTranslator |
getExceptionTranslator()
Exposes a shared
MongoExceptionTranslator . |
com.mongodb.DB |
getLegacyDb()
Deprecated.
since 2.1, use
getDb() . This method will be removed with a future version as it works only
with the legacy MongoDB driver. |
com.mongodb.client.ClientSession |
getSession(com.mongodb.ClientSessionOptions options)
Obtain a
ClientSession for given ClientSessionOptions. |
default boolean |
isTransactionActive()
|
MongoDbFactory |
withSession(com.mongodb.client.ClientSession session)
Obtain a
ClientSession bound instance of MongoDbFactory returning MongoDatabase instances
that are aware and bound to the given session. |
default MongoDbFactory |
withSession(com.mongodb.ClientSessionOptions options)
Obtain a
ClientSession bound instance of MongoDbFactory returning MongoDatabase instances
that are aware and bound to a new session with given options . |
getCodecFor, hasCodecFor
com.mongodb.client.MongoDatabase getDb() throws DataAccessException
MongoDatabase
instance.DataAccessException
com.mongodb.client.MongoDatabase getDb(String dbName) throws DataAccessException
DB
instance to access the database with the given name.dbName
- must not be null or empty.DataAccessException
PersistenceExceptionTranslator getExceptionTranslator()
MongoExceptionTranslator
.@Deprecated com.mongodb.DB getLegacyDb()
getDb()
. This method will be removed with a future version as it works only
with the legacy MongoDB driver.getDb()
instead.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 MongoDbFactory withSession(com.mongodb.ClientSessionOptions options)
ClientSession
bound instance of MongoDbFactory
returning MongoDatabase
instances
that are aware and bound to a new session with given options
.options
- must not be null.MongoDbFactory withSession(com.mongodb.client.ClientSession session)
ClientSession
bound instance of MongoDbFactory
returning MongoDatabase
instances
that are aware and bound to the given session.session
- must not be null.default boolean isTransactionActive()
Copyright © 2011–2020 Pivotal Software, Inc.. All rights reserved.