Class MorphiaSessionImpl

  • All Implemented Interfaces:
    com.mongodb.client.ClientSession, com.mongodb.session.ClientSession, AdvancedDatastore, Datastore, MorphiaSession, Closeable, AutoCloseable

    public class MorphiaSessionImpl
    extends BaseMorphiaSession
    Since:
    2.0
    Developer note.
    This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
    Developer note.
    This is an experimental item. Its function and presence are subject to change. Feedback on features and usability extremely welcome.
    • Constructor Detail

      • MorphiaSessionImpl

        public MorphiaSessionImpl​(com.mongodb.client.ClientSession session,
                                  com.mongodb.client.MongoClient mongoClient,
                                  com.mongodb.client.MongoDatabase database,
                                  Mapper mapper,
                                  QueryFactory queryFactory)
        Creates a new session.
        Parameters:
        session - the client session
        database - the database
        mapper - the mapper
        mongoClient - the client
        queryFactory - the factory
    • Method Detail

      • insert

        public <T> void insert​(T entity,
                               InsertOneOptions options)
        Description copied from interface: Datastore
        Inserts an entity in to the mapped collection.
        Specified by:
        insert in interface Datastore
        Overrides:
        insert in class DatastoreImpl
        Type Parameters:
        T - the type of the entity
        Parameters:
        entity - the entity to insert
        options - the options to apply to the insert operation
      • insert

        public <T> void insert​(List<T> entities,
                               InsertManyOptions options)
        Description copied from interface: Datastore
        Inserts entities in to the mapped collection.
        Specified by:
        insert in interface Datastore
        Overrides:
        insert in class DatastoreImpl
        Type Parameters:
        T - the type of the entity
        Parameters:
        entities - the entities to insert
        options - the options to apply to the insert operation
      • delete

        public <T> com.mongodb.client.result.DeleteResult delete​(T entity,
                                                                 DeleteOptions options)
        Description copied from class: DatastoreImpl
        Deletes the given entity (by @Id), with the WriteConcern
        Specified by:
        delete in interface Datastore
        Overrides:
        delete in class DatastoreImpl
        Type Parameters:
        T - the type to delete
        Parameters:
        entity - the entity to delete
        options - the options to use when deleting
        Returns:
        results of the delete
      • merge

        public <T> T merge​(T entity,
                           InsertOneOptions options)
        Description copied from interface: Datastore
        Work as if you did an update with each field in the entity doing a $set; Only at the top level of the entity.
        Specified by:
        merge in interface Datastore
        Overrides:
        merge in class DatastoreImpl
        Type Parameters:
        T - the type of the entity
        Parameters:
        entity - the entity to merge back in to the database
        options - the options to apply
        Returns:
        the new merged entity. NOTE: this is a database fetch.
      • save

        public <T> List<T> save​(List<T> entities,
                                InsertManyOptions options)
        Description copied from interface: Datastore
        Saves the entities (Objects) and updates the @Id field
        Specified by:
        save in interface Datastore
        Overrides:
        save in class DatastoreImpl
        Type Parameters:
        T - the type of the entity
        Parameters:
        entities - the entities to save
        options - the options to apply to the save operation
        Returns:
        the saved entities
      • save

        public <T> T save​(T entity,
                          InsertOneOptions options)
        Description copied from interface: Datastore
        Saves an entity (Object) and updates the @Id field
        Specified by:
        save in interface Datastore
        Overrides:
        save in class DatastoreImpl
        Type Parameters:
        T - the type of the entity
        Parameters:
        entity - the entity to save
        options - the options to apply to the save operation
        Returns:
        the saved entity