Package dev.morphia

Class Morphia


  • public final class Morphia
    extends Object
    Entry point for working with Morphia
    • Method Detail

      • createDatastore

        public static Datastore createDatastore​(String dbName)
        Deprecated.
        use createDatastore(MongoClient) and provide a configuration file instead. See the website docs for more detail
        Creates a Datastore
        Parameters:
        dbName - the name of the database
        Returns:
        a Datastore that you can use to interact with MongoDB
      • createDatastore

        public static Datastore createDatastore​(String dbName,
                                                MapperOptions options)
        Creates a Datastore
        Parameters:
        dbName - the name of the database
        options - the mapping options to use.
        Returns:
        a Datastore that you can use to interact with MongoDB
      • createDatastore

        public static Datastore createDatastore​(com.mongodb.client.MongoClient mongoClient,
                                                String dbName,
                                                MapperOptions options)
        It is best to use a Mongo singleton instance here.
        Parameters:
        mongoClient - the client to use
        dbName - the name of the database
        options - the mapping options to use.
        Returns:
        a Datastore that you can use to interact with MongoDB
      • createDatastore

        public static Datastore createDatastore​(com.mongodb.client.MongoClient mongoClient,
                                                String dbName)
        It is best to use a Mongo singleton instance here.
        Parameters:
        mongoClient - the client to use
        dbName - the name of the database
        Returns:
        a Datastore that you can use to interact with MongoDB
      • createDatastore

        public static Datastore createDatastore​(com.mongodb.client.MongoClient mongoClient)
        Creates a Datastore configured via config file. If no config file exists, then defaults will be applied as defined in the MorphiaConfig interface.
        Parameters:
        mongoClient - the client to use
        Returns:
        a Datastore that you can use to interact with MongoDB
        Since:
        2.4.0
      • createDatastore

        public static Datastore createDatastore​(com.mongodb.client.MongoClient mongoClient,
                                                ClassLoader classLoader)
        Creates a Datastore configured via config file using the given classloader for resource and class resolution.
        Parameters:
        mongoClient - the client to use
        classLoader - the classloader to use
        Returns:
        a Datastore that you can use to interact with MongoDB
        Since:
        2.6
      • createDatastore

        public static Datastore createDatastore​(com.mongodb.client.MongoClient mongoClient,
                                                MorphiaConfig config)
        Creates a Datastore configured via config file
        Parameters:
        mongoClient - the client to use
        config - the configuration to use
        Returns:
        a Datastore that you can use to interact with MongoDB
      • createDatastore

        public static Datastore createDatastore​(com.mongodb.client.MongoClient mongoClient,
                                                MorphiaConfig config,
                                                ClassLoader classLoader)
        Creates a Datastore with the given configuration and classloader.
        Parameters:
        mongoClient - the client to use
        config - the configuration to use
        classLoader - the classloader to use for class and resource resolution
        Returns:
        a Datastore that you can use to interact with MongoDB
        Since:
        2.6