org.springframework.data.mongodb

Interface MongoDbFactory

    • Method Detail

      • getDb

        com.mongodb.client.MongoDatabase getDb(String dbName)
                                        throws DataAccessException
        Creates a DB instance to access the database with the given name.
        Parameters:
        dbName - must not be null or empty.
        Returns:
        Throws:
        DataAccessException
      • getLegacyDb

        @Deprecated
        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.
        Get the legacy database entry point. Please consider getDb() instead.
        Returns:
      • getCodecRegistry

        default org.bson.codecs.configuration.CodecRegistry getCodecRegistry()
        Get the underlying CodecRegistry used by the MongoDB Java driver.
        Specified by:
        getCodecRegistry in interface CodecRegistryProvider
        Returns:
        never null.
      • getSession

        com.mongodb.client.ClientSession getSession(com.mongodb.ClientSessionOptions options)
        Obtain a ClientSession for given ClientSessionOptions.
        Specified by:
        getSession in interface MongoSessionProvider
        Parameters:
        options - must not be null.
        Returns:
        never null.
        Since:
        2.1
      • withSession

        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.
        Parameters:
        options - must not be null.
        Returns:
        never null.
        Since:
        2.1
      • withSession

        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.
        Parameters:
        session - must not be null.
        Returns:
        never null.
        Since:
        2.1