Package dev.morphia.experimental
Class MorphiaSessionImpl
- java.lang.Object
-
- dev.morphia.DatastoreImpl
-
- dev.morphia.experimental.BaseMorphiaSession
-
- dev.morphia.experimental.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 Summary
Constructors Constructor Description MorphiaSessionImpl(com.mongodb.client.ClientSession session, com.mongodb.client.MongoClient mongoClient, com.mongodb.client.MongoDatabase database, Mapper mapper, QueryFactory queryFactory)
Creates a new session.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> com.mongodb.client.result.DeleteResult
delete(T entity, DeleteOptions options)
Deletes the given entity (by @Id), with the WriteConcern<T> void
insert(List<T> entities, InsertManyOptions options)
Inserts entities in to the mapped collection.<T> void
insert(T entity, InsertOneOptions options)
Inserts an entity in to the mapped collection.<T> T
merge(T entity, InsertOneOptions options)
Work as if you did an update with each field in the entity doing a $set; Only at the top level of the entity.<T> List<T>
save(List<T> entities, InsertManyOptions options)
Saves the entities (Objects) and updates the @Id field<T> T
save(T entity, InsertOneOptions options)
Saves an entity (Object) and updates the @Id field-
Methods inherited from class dev.morphia.experimental.BaseMorphiaSession
abortTransaction, advanceClusterTime, advanceOperationTime, close, commitTransaction, getClusterTime, getOperationTime, getOptions, getOriginator, getPinnedServerAddress, getRecoveryToken, getServerSession, getSession, getTransactionOptions, hasActiveTransaction, isCausallyConsistent, notifyMessageSent, setPinnedServerAddress, setRecoveryToken, startTransaction, startTransaction, withTransaction, withTransaction
-
Methods inherited from class dev.morphia.DatastoreImpl
aggregate, aggregate, createAggregation, createAggregation, delete, enableDocumentValidation, enableValidation, ensureCaps, ensureIndexes, ensureIndexes, find, find, find, findSession, getDatabase, getLoggedQuery, getMapper, getQueryFactory, insert, insert, merge, queryByExample, queryByExample, refresh, save, saveDocument, setQueryFactory, startSession, startSession, withTransaction, withTransaction
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface dev.morphia.AdvancedDatastore
createAggregation, createQuery, createRef, createRef, createUpdateOperations, insert, insert, queryByExample
-
Methods inherited from interface dev.morphia.Datastore
aggregate, aggregate, createAggregation, createQuery, createUpdateOperations, delete, delete, delete, enableDocumentValidation, ensureCaps, ensureIndexes, ensureIndexes, find, find, find, findAndDelete, findAndDelete, findAndModify, findAndModify, findSession, getDatabase, getLoggedQuery, getMapper, getQueryFactory, insert, insert, merge, merge, queryByExample, refresh, save, save, save, save, save, setQueryFactory, startSession, startSession, update, update, withTransaction, withTransaction
-
-
-
-
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 sessiondatabase
- the databasemapper
- the mappermongoClient
- the clientqueryFactory
- 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 interfaceDatastore
- Overrides:
insert
in classDatastoreImpl
- Type Parameters:
T
- the type of the entity- Parameters:
entity
- the entity to insertoptions
- 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 interfaceDatastore
- Overrides:
insert
in classDatastoreImpl
- Type Parameters:
T
- the type of the entity- Parameters:
entities
- the entities to insertoptions
- 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 interfaceDatastore
- Overrides:
delete
in classDatastoreImpl
- Type Parameters:
T
- the type to delete- Parameters:
entity
- the entity to deleteoptions
- 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 interfaceDatastore
- Overrides:
merge
in classDatastoreImpl
- Type Parameters:
T
- the type of the entity- Parameters:
entity
- the entity to merge back in to the databaseoptions
- 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 interfaceDatastore
- Overrides:
save
in classDatastoreImpl
- Type Parameters:
T
- the type of the entity- Parameters:
entities
- the entities to saveoptions
- 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 interfaceDatastore
- Overrides:
save
in classDatastoreImpl
- Type Parameters:
T
- the type of the entity- Parameters:
entity
- the entity to saveoptions
- the options to apply to the save operation- Returns:
- the saved entity
-
-