Package de.caluga.morphium
Class Morphium
java.lang.Object
de.caluga.morphium.Morphium
- All Implemented Interfaces:
AutoCloseable
This is the single access point for accessing MongoDB. This should
- Author:
- stephan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidvoidvoidMap<Class<?>,List<IndexDescription>> run trhough classpath, find all Entities, check indices returns a list of Entities, whos indices are missing or differentMap<Class<?>,List<IndexDescription>> checkIndices(io.github.classgraph.ClassInfoList.ClassInfoFilter filter) voidclearCachefor(Class<?> cls) Erase cache entries for the given type. is being called after every store depending on cache settings!voidclearCacheforClassIfNecessary(Class<?> cls) voidclearCollection(Class<?> cls) issues a remove command - no lifecycle methods calles, no drop, keeps all indexec this wayvoidclearCollection(Class<?> cls, String colName) issues a remove command - no lifecycle methods calles, no drop, keeps all indexec this way But uses sepcified collection name instead deriving name from classvoidclearCollectionOneByOne(Class<?> cls) clears every single object in collection - reads ALL objects to do so this way Lifecycle methods can be called!voidclose()void<T> voidconvertToCapped(Class<T> c, int size, int max, AsyncOperationCallback<T> cb) converts the given type to capped collection in Mongo, even if no @capped is defined!<T> voidconvertToCapped(String collectionName, int size, int max, AsyncOperationCallback<T> cb) <T,R> Aggregator<T, R> createAggregator(Class<? extends T> type, Class<? extends R> resultType) createBulkRequestContext(Class<?> type, boolean ordered) createBulkRequestContext(String collection, boolean ordered) <T> voidcreateIndex(Class<T> cls, String collection, IndexDescription index, AsyncOperationCallback<T> callback) createIndexKeyMapFrom(String[] fldStr) <T> TcreateLazyLoadedEntity(Class<? extends T> cls, Object id, String collectionName) createMapQuery(String collection) <T> Query<T>createQueryByTemplate(T template, String... fields) <T> Query<T>createQueryFor(Class<? extends T> type) <T> Query<T>createQueryFor(Class<? extends T> type, String usingCollectionName) <T> voidcurrentDate(Query<?> query, Enum field, boolean upsert, boolean multiple) <T> voidcurrentDate(Query<?> query, String field, boolean upsert, boolean multiple) set current date into one fieldvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoid<T> voiddec(Query<T> query, Enum field, double amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) <T> voiddec(Query<T> query, Enum field, int amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) <T> voiddec(Query<T> query, Enum field, long amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) <T> voiddec(Query<T> query, Enum field, Number amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) <T> voiddec(Query<T> query, String name, double amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) <T> voiddec(Query<T> query, String name, int amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) <T> voiddec(Query<T> query, String name, long amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) <T> voiddec(Query<T> query, String name, Number amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) <T> voiddec(Query<T> query, Map<String, Number> toUpdate, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) voiddecreasing a value of a given object callesinc(toDec,field,-amount);voidvoidvoidvoidvoidvoidvoid<T> voiddec(Map<Enum, Number> fieldsToInc, Query<T> matching, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) <T> void<T> voiddelete(Query<T> o, AsyncOperationCallback<T> callback) voiddeletes a single object from morphium backend.void<T> voiddelete(List<T> lst, AsyncOperationCallback<T> callback) <T> void<T> voiddelete(List<T> lst, String forceCollectionName, AsyncOperationCallback<T> callback) <T> voiddelete(T lo, AsyncOperationCallback<T> callback) <T> voiddelete(T lo, String collection, AsyncOperationCallback<T> callback) <T> TdeReference(T obj) de-references the given object of type T.voidvoidvoidvoidvoidreturns a distinct list of values of the given collection Attention: these values are not unmarshalled, you might get MongoMapinvalid input: '<'String,Object>sreturns a distinct list of values of the given collection Attention: these values are not unmarshalled, you might get MongoMapinvalid input: '<'String,Object>svoiddropCollection(Class<?> cls) <T> voiddropCollection(Class<T> cls, AsyncOperationCallback<T> callback) <T> voiddropCollection(Class<T> cls, String collection, AsyncOperationCallback<T> callback) voidvoidvoidvoidvoid<T> voidensureCapped(Class<T> c) automatically convert the collection for the given type to a capped collection only works if @Capped annotation is given for type<T> voidensureCapped(Class<T> c, AsyncOperationCallback<T> callback) voidensureIndex(Class<?> cls, Enum... fldStr) voidensureIndex(Class<?> cls, String... fldStr) voidDeprecated.voidDeprecated.voidensureIndex(Class<?> cls, Map<String, Object> index) Deprecated.<T> voidensureIndex(Class<T> cls, AsyncOperationCallback<T> callback, Enum... fldStr) Deprecated.<T> voidensureIndex(Class<T> cls, AsyncOperationCallback<T> callback, String... fldStr) Deprecated.<T> voidensureIndex(Class<T> cls, String collection, AsyncOperationCallback<T> callback, Enum... fldStr) Deprecated.<T> voidensureIndex(Class<T> cls, String collection, AsyncOperationCallback<T> callback, String... fldStr) Deprecated.<T> voidensureIndex(Class<T> cls, String collection, Map<String, Object> index, AsyncOperationCallback<T> callback) Deprecated.<T> voidensureIndex(Class<T> cls, String collection, Map<String, Object> index, Map<String, Object> options, AsyncOperationCallback<T> callback) Deprecated.<T> voidensureIndex(Class<T> cls, Map<String, Object> index, AsyncOperationCallback<T> callback) Deprecated.<T> voidensureIndicesFor(Class<T> type) can be called for autmatic index ensurance.<T> voidensureIndicesFor(Class<T> type, AsyncOperationCallback<T> callback) <T> voidensureIndicesFor(Class<T> type, String onCollection) <T> voidensureIndicesFor(Class<T> type, String onCollection, AsyncOperationCallback<T> callback) <T> voidensureIndicesFor(Class<T> type, String onCollection, AsyncOperationCallback<T> callback, MorphiumWriter wr) booleanboolean<T> List<T>Deprecated.<T> List<T>findByField(Class<? extends T> cls, Enum fld, Object val) <T> List<T>findByField(Class<? extends T> cls, String fld, Object val) <T> T<T> T<T> voidfindById(Class<? extends T> type, Object id, String collection, AsyncOperationCallback callback) voidfirePostDropEvent(Class cls) <T> voidfirePostLoad(List<T> loaded) voidwill be called by query after unmarshalling<T> voidfirePostRemove(List<T> toRemove) voidvoidvoidfirePostStore(Object o, boolean isNew) <T> voidfirePostStore(Map<T, Boolean> isNew) voidvoidfirePreDrop(Class cls) void<T> voidfirePreRemove(List<T> lst) voidvoidfirePreStore(Object o, boolean isNew) voidfirePreStore(Map<Object, Boolean> isNew) voidvoidfireProfilingReadEvent(Query q, long time, ReadAccessType t) voidfireProfilingWriteEvent(Class type, Object data, long time, boolean isNew, WriteAccessType wt) voidflush()voidintintintgetCache()getCollStats(Class<?> coll) getCollStats(String coll) getDbStats(String db) <T> List<IndexDescription>getIndexesFromEntity(Class<T> type) getIndexesFromMongo(Class cls) getIndexesFromMongo(String collection) getMissingIndicesFor(Class<?> entity) getMissingIndicesFor(Class<?> entity, String collection) getNameProviderForClass(Class<?> cls) intgetReadPreferenceForClass(Class<?> cls) getStats()intgetWriteConcernForClass(Class<?> cls) intgetWriterForClass(Class<?> cls) voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoid<T> voidinc(Query<T> query, Enum field, double amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) <T> voidinc(Query<T> query, Enum field, int amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) <T> voidinc(Query<T> query, Enum field, long amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) <T> voidinc(Query<T> query, Enum field, Number amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) <T> voidinc(Query<T> query, String name, double amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) <T> voidinc(Query<T> query, String name, int amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) <T> voidinc(Query<T> query, String name, long amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) <T> voidinc(Query<T> query, String name, Number amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) <T> voidinc(Query<T> query, Map<String, Number> toUpdate, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) voidinc(StatisticKeys k) voidvoidvoidvoidvoidvoidvoidvoid<T> voidinc(Map<Enum, Number> fieldsToInc, Query<T> matching, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) <T> voidinc(T toSet, Enum field, double i, AsyncOperationCallback<T> callback) <T> voidinc(T toSet, Enum field, int i, AsyncOperationCallback<T> callback) <T> voidinc(T toSet, Enum field, long i, AsyncOperationCallback<T> callback) <T> voidinc(T toSet, Enum collection, Enum field, double i, AsyncOperationCallback<T> callback) <T> voidinc(T toSet, Enum field, Number i, AsyncOperationCallback<T> callback) <T> voidinc(T toSet, String field, double i, AsyncOperationCallback<T> callback) <T> voidinc(T toSet, String field, int i, AsyncOperationCallback<T> callback) <T> voidinc(T toSet, String field, long i, AsyncOperationCallback<T> callback) <T> voidinc(T toSet, String collection, Enum field, double i, AsyncOperationCallback<T> callback) <T> voidinc(T toSet, String collection, Enum field, int i, AsyncOperationCallback<T> callback) <T> voidinc(T toSet, String collection, Enum field, long i, AsyncOperationCallback<T> callback) <T> voidinc(T toSet, String collection, Enum field, Number i, AsyncOperationCallback<T> callback) <T> voidinc(T toSet, String field, Number i, AsyncOperationCallback<T> callback) <T> voidinc(T toSet, String collection, String field, double i, AsyncOperationCallback<T> callback) <T> voidinc(T toSet, String collection, String field, int i, AsyncOperationCallback<T> callback) <T> voidinc(T toSet, String collection, String field, long i, AsyncOperationCallback<T> callback) <T> voidinc(T toSet, String collection, String field, Number i, AsyncOperationCallback<T> callback) <T> voidinsert(T o) <T> voidinsert(T o, AsyncOperationCallback<T> callback) booleanbooleanbooleanbooleanbooleanChecks if javax.validation is available and enables validation support.booleanlistCollections(String pattern) <T> List<T>voidvoidvoid<T> voidpull(Query<T> query, String field, Expr value, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) <T> void<T> voidpull(Query<T> query, String field, Object value, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) Asynchronous call to pulll<T> voidpull(T entity, String field, Expr value, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) voidvoid<T> voidpullAll(Query<T> query, String field, List<?> value, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) voidvoidvoid<T> void<T> voidpush(Query<T> query, String field, Object value, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) asynchronous call to callbackvoidvoidvoidvoidvoidvoid<T> voidpushAll(Query<T> query, String field, List<?> value, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) <T> voidpushPull(boolean push, Query<T> query, String field, Object value, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) <T> voidpushPullAll(boolean push, Query<T> query, String field, List<?> value, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) void<T> List<T>return a list of all elements stored in morphium for this typevoidreconnectToDb(String db) voidvoidvoidvoid<T> Treread(T o) careful this actually changes the parameter o!<T> Tvoidreset()void<T> voidsave(List<T> lst, AsyncOperationCallback<T> callback) <T> voidsave(T o) <T> voidsave(T o, AsyncOperationCallback<T> callback) <T> voidsave(T o, String collection, AsyncOperationCallback<T> callback) <T> void<T> voidsaveList(List<T> lst, AsyncOperationCallback<T> callback) <T> void<T> voidsaveList(List<T> lst, String collection, AsyncOperationCallback<T> callback) <T> voidvoid<T> void<T> voidwill change an entry in mongodb-collection corresponding to given class object if query is too complex, upsert might not work!<T> voidset(Query<T> query, Enum field, Object val, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) <T> voidset(Query<T> query, Enum field, Object val, AsyncOperationCallback<T> callback) <T> void<T> void<T> voidset(Query<T> query, String field, Object val, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) <T> voidset(Query<T> query, String field, Object val, AsyncOperationCallback<T> callback) <T> voidset(Query<T> query, Map<String, Object> map, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) <T> void<T> void<T> void<T> voidset(T toSet, Enum field, Object value, boolean upserts, AsyncOperationCallback<T> callback) <T> voidset(T toSet, Enum field, Object value, AsyncOperationCallback<T> callback) <T> void<T> voidset(T toSet, String collection, boolean upserts, Map<Enum, Object> values, AsyncOperationCallback<T> callback) <T> void<T> voidset(T toSet, String collection, Enum field, Object value, boolean upserts, AsyncOperationCallback<T> callback) <T> voidsetting a value in an existing mongo collection entry - no reading necessary.<T> voidset(T toSet, String field, Object value, boolean upserts, AsyncOperationCallback<T> callback) <T> voidset(T toSet, String field, Object value, AsyncOperationCallback<T> callback) <T> voidset(T toSet, String collection, String field, Object value, boolean upserts, AsyncOperationCallback<T> callback) <T> void<T> void<T> voidset(T toSet, String collection, Map<String, Object> values, boolean upserts, AsyncOperationCallback<T> callback) <T> void<T> booleansetAutoValues(T o) voidsetConfig(MorphiumConfig cfg) voidsetDriver(MorphiumDriver drv) voidvoidsetNameProviderForClass(Class<?> cls, NameProvider pro) voidvoid<T> voidstore(List<T> lst, AsyncOperationCallback<T> callback) <T> voidstore(List<T> lst, String collectionName, AsyncOperationCallback<T> callback) <T> voidstore(T o) Stores a single Object.<T> voidstore(T o, AsyncOperationCallback<T> callback) <T> voidstore(T o, String collection, AsyncOperationCallback<T> callback) <T> voidstoreBuffered(T lst) <T> voidstoreBuffered(T lst, AsyncOperationCallback<T> callback) <T> voidstoreBuffered(T lst, String collection, AsyncOperationCallback<T> callback) <T> voidsorts elements in this list, whether to store in background or directly.<T> voidstoreList(List<T> lst, AsyncOperationCallback<T> callback) <T> voidstores all elements of this list to the given collection<T> voidstoreList(List<T> lst, String collection, AsyncOperationCallback<T> callback) <T> voiddirectly writes data to Mongo, no Mapper used use with caution, as caches are not updated also no checks for validity of fields, no references, no auto-variables no async writing!directly writes data to Mongo, no Mapper used use with caution, as caches are not updated also no checks for validity of fields, no references, no auto-variables no async writing!directly writes data to Mongo, no Mapper used use with caution, as caches are not updated also no checks for validity of fields, no references, no auto-variables no async writing!directly writes data to Mongo, no Mapper used use with caution, as caches are not updated also no checks for validity of fields, no references, no auto-variables no async writing!<T> voidstoreNoCache(T lst) <T> voidstoreNoCache(T o, AsyncOperationCallback<T> callback) <T> voidstoreNoCache(T o, String collection) <T> voidstoreNoCache(T o, String collection, AsyncOperationCallback<T> callback) toString()<T> void<T> voidunset(T toSet, Enum field, AsyncOperationCallback<T> callback) <T> void<T> voidunset(T toSet, String field, AsyncOperationCallback<T> callback) <T> void<T> voidunset(T toSet, String collection, Enum field, AsyncOperationCallback<T> callback) <T> voidunset(T toSet, String collection, String field, AsyncOperationCallback<T> callback) <T> voidunsetQ(Query<T> q, boolean multiple, AsyncOperationCallback<T> cb, Enum... field) <T> void<T> void<T> voidunsetQ(Query<T> q, AsyncOperationCallback<T> cb, boolean multiple, String... field) <T> voidunsetQ(Query<T> q, AsyncOperationCallback<T> cb, Enum... field) <T> voidunsetQ(Query<T> q, AsyncOperationCallback<T> cb, String... field) <T> void<T> voidvoidupdateUsingFields(Object ent, Enum... fieldNames) voidupdateUsingFields(Object ent, String... fields) updating an enty in DB without sending the whole entity only transfers the fields to be changed / set<T> voidupdateUsingFields(T ent, AsyncOperationCallback<T> callback, Enum... fields) <T> voidupdateUsingFields(T ent, AsyncOperationCallback<T> callback, String... fields) <T> voidupdateUsingFields(T ent, String collection, AsyncOperationCallback<T> callback, Enum... fields) <T> voidupdateUsingFields(T ent, String collection, AsyncOperationCallback<T> callback, String... fields) <T> voidwatch(Class<T> entity, boolean updateFull, ChangeStreamListener lst) <T> voidwatch(Class<T> entity, boolean updateFull, List<Map<String, Object>> pipeline, ChangeStreamListener lst) <T> voidwatch(String collectionName, boolean updateFull, ChangeStreamListener lst) <T> voidwatch(String collectionName, boolean updateFull, List<Map<String, Object>> pipeline, ChangeStreamListener lst) <T> voidwatch(String collectionName, int maxWaitTime, boolean updateFull, List<Map<String, Object>> pipeline, ChangeStreamListener lst) <T> voidwatchAsync(Class<T> entity, boolean updateFull, ChangeStreamListener lst) <T> voidwatchAsync(Class<T> entity, boolean updateFull, List<Map<String, Object>> pipeline, ChangeStreamListener lst) <T> voidwatchAsync(String collectionName, boolean updateFull, ChangeStreamListener lst) <T> voidwatchAsync(String collectionName, boolean updateFull, List<Map<String, Object>> pipeline, ChangeStreamListener lst) <T> voidwatchDb(boolean updateFull, ChangeStreamListener lst) <T> voidwatchDb(String dbName, boolean updateFull, ChangeStreamListener lst) <T> voidwatchDb(String dbName, boolean updateFull, List<Map<String, Object>> pipeline, AtomicBoolean runningFlag, ChangeStreamListener lst) <T> voidwatchDb(String dbName, int maxWaitTime, boolean updateFull, List<Map<String, Object>> pipeline, AtomicBoolean runningFlag, ChangeStreamListener lst) <T> AtomicBooleanwatchDbAsync(boolean updateFull, AtomicBoolean runningFlag, ChangeStreamListener lst) <T> AtomicBooleanwatchDbAsync(boolean updateFull, List<Map<String, Object>> pipeline, ChangeStreamListener lst) <T> AtomicBooleanwatchDbAsync(String dbName, boolean updateFull, List<Map<String, Object>> pipeline, ChangeStreamListener lst) int
-
Constructor Details
-
Morphium
public Morphium() -
Morphium
-
Morphium
-
Morphium
init the MongoDbLayer. Uses Morphium-Configuration Object for Configuration. Needs to be set before use or RuntimeException is thrown! us used for de-referencing and automatical save of referenced entities all logging is done in INFO level- See Also:
-
-
Method Details
-
getConfig
-
setConfig
-
getAsyncOperationsThreadPool
-
getValueEncrpytionProvider
-
getEncryptionKeyProvider
-
getCache
-
isValidationEnabled
public boolean isValidationEnabled()Checks if javax.validation is available and enables validation support.- Returns:
- true, if validation is supported
-
disableValidation
public void disableValidation() -
enableValidation
public void enableValidation() -
listDatabases
-
listCollections
-
listCollections
-
reconnectToDb
-
addListener
-
removeListener
-
getDriver
-
setDriver
-
createMapQuery
-
createQueryByTemplate
-
unset
-
unset
-
unset
-
unset
-
unset
-
unset
-
unset
-
unsetQ
-
unsetQ
-
unsetQ
-
unsetQ
-
unsetQ
-
unsetQ
-
unsetQ
-
unsetQ
-
addReplicasetStatusListener
-
removeReplicasetStatusListener
-
convertToCapped
public <T> void convertToCapped(Class<T> c, int size, int max, AsyncOperationCallback<T> cb) throws MorphiumDriverException converts the given type to capped collection in Mongo, even if no @capped is defined! Warning: depending on size this might take some time!- Type Parameters:
T- type- Parameters:
c- entity typesize- size of capped collectioncb- callback- Throws:
MorphiumDriverException
-
convertToCapped
public <T> void convertToCapped(String collectionName, int size, int max, AsyncOperationCallback<T> cb) throws MorphiumDriverException - Throws:
MorphiumDriverException
-
ensureCapped
automatically convert the collection for the given type to a capped collection only works if @Capped annotation is given for type- Parameters:
c- - type
-
ensureCapped
-
simplifyQueryObject
-
set
-
set
-
set
-
set
-
setEnum
-
push
-
pull
-
push
-
pull
-
push
-
pull
-
pushAll
-
push
-
push
-
push
-
push
-
pullAll
-
push
-
push
public <T> void push(Query<T> query, String field, Object value, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) asynchronous call to callback- Type Parameters:
T- - the type- Parameters:
query- - the queryfield- - field to push values tovalue- - value to pushupsert- - insert object, if it does not existmultiple- - more than onecallback- - will be called, when operation succeeds - synchronous call, if null
-
pull
-
pull
public <T> void pull(Query<T> query, String field, Object value, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) Asynchronous call to pulll- Type Parameters:
T- - type- Parameters:
query- - queryfield- - field to pullvalue- - value to pull from fieldupsert- - insert document unless it existsmultiple- - more than onecallback- -callback to call when operation succeeds - synchronous call, if null
-
pull
public <T> void pull(T entity, String field, Expr value, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
pull
public <T> void pull(Query<T> query, String field, Expr value, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
pushAll
-
pushAll
public <T> void pushAll(Query<T> query, String field, List<?> value, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
set
will change an entry in mongodb-collection corresponding to given class object if query is too complex, upsert might not work! Upsert should consist of single anueries, which will be used to generate the object to create, unless it already exists. look at Mongodb-query documentation as well- Parameters:
query- - query to specify which objects should be setfield- - field to setval- - value to setupsert- - insert, if it does not exist (query needs to be simple!)multiple- - update several documents, if false, only first hit will be updated
-
set
public <T> void set(Query<T> query, Enum field, Object val, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
pullAll
-
set
-
set
public <T> void set(Query<T> query, String field, Object val, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
set
-
set
public <T> void set(Query<T> query, Map<String, Object> map, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
currentDate
set current date into one field- Type Parameters:
T-- Parameters:
query-field-upsert-multiple-
-
currentDate
-
set
-
set
-
set
-
set
public <T> void set(T toSet, Enum field, Object value, boolean upserts, AsyncOperationCallback<T> callback) -
set
-
set
-
set
-
set
public <T> void set(T toSet, String collection, boolean upserts, Map<Enum, Object> values, AsyncOperationCallback<T> callback) -
set
setting a value in an existing mongo collection entry - no reading necessary. Object is altered in place db.collection.update({"_id":toSet.id},{$set:{field:value}} attention: this alteres the given object toSet in a similar way- Parameters:
toSet- - object to set the value in (or better - the corresponding entry in mongo)field- - the field to changevalue- - the value to set
-
set
public <T> void set(T toSet, String field, Object value, boolean upserts, AsyncOperationCallback<T> callback) -
set
-
set
-
set
-
set
public <T> void set(T toSet, String collection, Map<String, Object> values, boolean upserts, AsyncOperationCallback<T> callback) -
getDbStats
- Throws:
MorphiumDriverException
-
getDbStats
- Throws:
MorphiumDriverException
-
getCollStats
- Throws:
MorphiumDriverException
-
getCollStats
- Throws:
MorphiumDriverException
-
set
public <T> void set(T toSet, String collection, Enum field, Object value, boolean upserts, AsyncOperationCallback<T> callback) -
set
public <T> void set(T toSet, String collection, String field, Object value, boolean upserts, AsyncOperationCallback<T> callback) -
set
-
dec
-
dec
-
dec
-
dec
-
dec
-
dec
-
dec
-
dec
-
dec
-
dec
-
dec
-
dec
-
dec
-
dec
-
dec
-
dec
-
inc
-
inc
-
inc
-
inc
-
inc
-
inc
-
inc
-
inc
-
inc
-
inc
-
inc
-
inc
-
inc
public <T> void inc(Map<Enum, Number> fieldsToInc, Query<T> matching, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
inc
public <T> void inc(Query<T> query, Map<String, Number> toUpdate, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
dec
public <T> void dec(Map<Enum, Number> fieldsToInc, Query<T> matching, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
dec
public <T> void dec(Query<T> query, Map<String, Number> toUpdate, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
inc
-
inc
-
inc
-
inc
-
inc
public <T> void inc(Query<T> query, Enum field, long amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
inc
public <T> void inc(Query<T> query, String name, long amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
inc
public <T> void inc(Query<T> query, Enum field, int amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
inc
public <T> void inc(Query<T> query, String name, int amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
inc
public <T> void inc(Query<T> query, Enum field, double amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
inc
public <T> void inc(Query<T> query, String name, double amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
inc
public <T> void inc(Query<T> query, Enum field, Number amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
inc
public <T> void inc(Query<T> query, String name, Number amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
dec
public <T> void dec(Query<T> query, Enum field, long amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
dec
public <T> void dec(Query<T> query, String name, long amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
dec
public <T> void dec(Query<T> query, Enum field, int amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
dec
public <T> void dec(Query<T> query, String name, int amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
dec
public <T> void dec(Query<T> query, Enum field, double amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
dec
public <T> void dec(Query<T> query, String name, double amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
dec
public <T> void dec(Query<T> query, Enum field, Number amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
dec
public <T> void dec(Query<T> query, String name, Number amount, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
getWriterForClass
-
dec
decreasing a value of a given object callesinc(toDec,field,-amount); -
dec
-
dec
-
dec
-
dec
-
dec
-
dec
-
dec
-
inc
-
inc
-
inc
-
inc
-
inc
-
inc
-
inc
-
inc
-
inc
-
inc
-
inc
-
inc
-
inc
-
inc
-
inc
-
inc
-
inc
public <T> void inc(T toSet, Enum collection, Enum field, double i, AsyncOperationCallback<T> callback) -
inc
public <T> void inc(T toSet, String collection, Enum field, double i, AsyncOperationCallback<T> callback) -
inc
public <T> void inc(T toSet, String collection, String field, double i, AsyncOperationCallback<T> callback) -
inc
public <T> void inc(T toSet, String collection, Enum field, int i, AsyncOperationCallback<T> callback) -
inc
public <T> void inc(T toSet, String collection, String field, int i, AsyncOperationCallback<T> callback) -
inc
public <T> void inc(T toSet, String collection, Enum field, long i, AsyncOperationCallback<T> callback) -
inc
public <T> void inc(T toSet, String collection, String field, long i, AsyncOperationCallback<T> callback) -
inc
public <T> void inc(T toSet, String collection, Enum field, Number i, AsyncOperationCallback<T> callback) -
inc
public <T> void inc(T toSet, String collection, String field, Number i, AsyncOperationCallback<T> callback) -
delete
-
delete
-
delete
-
inc
-
updateUsingFields
updating an enty in DB without sending the whole entity only transfers the fields to be changed / set- Parameters:
ent- - entity to updatefields- - fields to use
-
updateUsingFields
-
updateUsingFields
-
updateUsingFields
-
updateUsingFields
public <T> void updateUsingFields(T ent, String collection, AsyncOperationCallback<T> callback, Enum... fields) -
updateUsingFields
public <T> void updateUsingFields(T ent, String collection, AsyncOperationCallback<T> callback, String... fields) -
getMapper
-
getARHelper
-
reread
public <T> T reread(T o) careful this actually changes the parameter o!- Type Parameters:
T- - tpye of the object- Parameters:
o- - object to read- Returns:
- - entity
-
reread
-
firePreStore
-
firePostStore
-
firePreDrop
-
firePostStore
-
firePostRemove
-
firePostLoad
-
firePreStore
-
firePreRemove
-
firePreRemove
-
firePostDropEvent
-
firePostUpdateEvent
-
firePreUpdateEvent
-
firePostRemoveEvent
-
firePostRemoveEvent
-
firePreRemoveEvent
-
deReference
public <T> T deReference(T obj) de-references the given object of type T. If itself or any of its members is a Proxy (PartiallyUpdateableProxy or LazyDeReferencingProxy), it'll be removed and replaced by the real objet. This is not recursive, only the members here are de-referenced- Type Parameters:
T- - type- Parameters:
obj- - the object to replact- Returns:
- the dereferenced object
-
setNameProviderForClass
-
getNameProviderForClass
-
firePostLoadEvent
will be called by query after unmarshalling- Parameters:
o- - entitiy
-
getCurrentRSState
-
isReplicaSet
public boolean isReplicaSet() -
getReadPreferenceForClass
-
createBulkRequestContext
-
createBulkRequestContext
-
getWriteConcernForClass
-
addProfilingListener
-
removeProfilingListener
-
fireProfilingWriteEvent
public void fireProfilingWriteEvent(Class type, Object data, long time, boolean isNew, WriteAccessType wt) -
fireProfilingReadEvent
-
clearCollection
issues a remove command - no lifecycle methods calles, no drop, keeps all indexec this way- Parameters:
cls- - class
-
clearCollection
issues a remove command - no lifecycle methods calles, no drop, keeps all indexec this way But uses sepcified collection name instead deriving name from class- Parameters:
cls- - classcolName- - CollectionName
-
clearCollectionOneByOne
clears every single object in collection - reads ALL objects to do so this way Lifecycle methods can be called!- Parameters:
cls- -class
-
readAll
return a list of all elements stored in morphium for this type- Type Parameters:
T- - Type- Parameters:
cls- - type to search for, needs to be an Property- Returns:
- - list of all elements stored
-
createQueryFor
-
createQueryFor
-
find
Deprecated.use query.asList() instead- Type Parameters:
T-- Parameters:
q-- Returns:
-
distinct
-
distinct
returns a distinct list of values of the given collection Attention: these values are not unmarshalled, you might get MongoMapinvalid input: '<'String,Object>s -
distinct
returns a distinct list of values of the given collection Attention: these values are not unmarshalled, you might get MongoMapinvalid input: '<'String,Object>s -
distinct
-
distinct
-
distinct
-
distinct
-
findById
-
findById
public <T> void findById(Class<? extends T> type, Object id, String collection, AsyncOperationCallback callback) -
findById
-
findByField
-
findByField
-
setAutoValues
- Throws:
IllegalAccessException
-
clearCachefor
Erase cache entries for the given type. is being called after every store depending on cache settings!- Parameters:
cls- - class
-
clearCacheforClassIfNecessary
-
storeNoCache
public <T> void storeNoCache(T lst) -
storeNoCache
-
storeNoCache
-
storeNoCache
-
storeBuffered
public <T> void storeBuffered(T lst) -
storeBuffered
-
storeBuffered
-
flush
public void flush() -
flush
-
getId
-
dropCollection
-
dropCollection
-
dropCollection
-
ensureIndicesFor
can be called for autmatic index ensurance. Attention: might cause heavy load on mongo- Parameters:
type- type to ensure indices for
-
ensureIndicesFor
-
ensureIndicesFor
-
ensureIndicesFor
public <T> void ensureIndicesFor(Class<T> type, String onCollection, AsyncOperationCallback<T> callback) -
ensureIndicesFor
public <T> void ensureIndicesFor(Class<T> type, String onCollection, AsyncOperationCallback<T> callback, MorphiumWriter wr) -
ensureIndex
Deprecated. -
ensureIndex
@Deprecated public void ensureIndex(Class<?> cls, String collection, Map<String, Object> index, Map<String, Object> options) Deprecated. -
ensureIndex
Deprecated. -
ensureIndex
@Deprecated public <T> void ensureIndex(Class<T> cls, AsyncOperationCallback<T> callback, Enum... fldStr) Deprecated.ensureIndex(CachedObject.class,"counter","-value"); ensureIndex(CachedObject.class,"counter:2d","-value); Similar to sorting- Parameters:
cls- - classfldStr- - fields
-
ensureIndex
@Deprecated public <T> void ensureIndex(Class<T> cls, String collection, AsyncOperationCallback<T> callback, Enum... fldStr) Deprecated. -
ensureIndex
@Deprecated public <T> void ensureIndex(Class<T> cls, AsyncOperationCallback<T> callback, String... fldStr) Deprecated. -
ensureIndex
@Deprecated public <T> void ensureIndex(Class<T> cls, String collection, AsyncOperationCallback<T> callback, String... fldStr) Deprecated. -
ensureIndex
@Deprecated public <T> void ensureIndex(Class<T> cls, Map<String, Object> index, AsyncOperationCallback<T> callback) Deprecated. -
ensureIndex
@Deprecated public <T> void ensureIndex(Class<T> cls, String collection, Map<String, Object> index, Map<String, Object> options, AsyncOperationCallback<T> callback) Deprecated. -
ensureIndex
@Deprecated public <T> void ensureIndex(Class<T> cls, String collection, Map<String, Object> index, AsyncOperationCallback<T> callback) Deprecated. -
createIndex
public <T> void createIndex(Class<T> cls, String collection, IndexDescription index, AsyncOperationCallback<T> callback) -
getIndexesFromMongo
-
getIndexesFromMongo
-
getIndexesFromEntity
-
writeBufferCount
public int writeBufferCount() -
store
-
createIndexKeyMapFrom
-
getDatabase
-
ensureIndex
-
ensureIndex
-
insert
public <T> void insert(T o) -
insert
-
storeMaps
public Map<String,Integer> storeMaps(Class type, List<Map<String, Object>> lst) throws MorphiumDriverExceptiondirectly writes data to Mongo, no Mapper used use with caution, as caches are not updated also no checks for validity of fields, no references, no auto-variables no async writing!- Parameters:
type- - type to write to (just for determining collection name)lst- - list of entries to write- Returns:
- statistics
- Throws:
MorphiumDriverException
-
saveMaps
public Map<String,Integer> saveMaps(Class type, List<Map<String, Object>> lst) throws MorphiumDriverException- Throws:
MorphiumDriverException
-
storeMaps
public Map<String,Integer> storeMaps(String collection, List<Map<String, Object>> lst) throws MorphiumDriverExceptiondirectly writes data to Mongo, no Mapper used use with caution, as caches are not updated also no checks for validity of fields, no references, no auto-variables no async writing!- Parameters:
collection- - name of colleciton to write tolst- - list of entries to write- Returns:
- statistics
- Throws:
MorphiumDriverException
-
saveMaps
public Map<String,Integer> saveMaps(String collection, List<Map<String, Object>> lst) throws MorphiumDriverException- Throws:
MorphiumDriverException
-
storeMap
public Map<String,Integer> storeMap(String collection, Map<String, Object> m) throws MorphiumDriverExceptiondirectly writes data to Mongo, no Mapper used use with caution, as caches are not updated also no checks for validity of fields, no references, no auto-variables no async writing!- Parameters:
collection- collection namem- data to write- Returns:
- statistics
- Throws:
MorphiumDriverException
-
saveMap
public Map<String,Integer> saveMap(String collection, Map<String, Object> m) throws MorphiumDriverException- Throws:
MorphiumDriverException
-
storeMap
directly writes data to Mongo, no Mapper used use with caution, as caches are not updated also no checks for validity of fields, no references, no auto-variables no async writing!- Parameters:
type- - type, used to determine collection namem- - data to write- Returns:
- statistics
- Throws:
MorphiumDriverException
-
store
public <T> void store(T o) Stores a single Object. Clears the corresponding cache- Parameters:
o- - Object to store
-
save
public <T> void save(T o) -
store
-
save
-
store
-
save
-
save
-
store
-
storeList
stores all elements of this list to the given collection- Type Parameters:
T- - type of entity- Parameters:
lst- - list of objects to storecollection- - collection name to use
-
saveList
-
storeList
-
saveList
-
storeList
sorts elements in this list, whether to store in background or directly.- Type Parameters:
T- - type of list elements- Parameters:
lst- - all objects are sorted whether to store in BG or direclty. All objects are stored in their corresponding collection
-
saveList
-
storeList
-
saveList
-
storeList
-
saveList
-
delete
-
delete
-
pushPull
public <T> void pushPull(boolean push, Query<T> query, String field, Object value, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
pushPullAll
public <T> void pushPullAll(boolean push, Query<T> query, String field, List<?> value, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
pullAll
public <T> void pullAll(Query<T> query, String field, List<?> value, boolean upsert, boolean multiple, AsyncOperationCallback<T> callback) -
delete
deletes a single object from morphium backend. Clears cache- Parameters:
o- - entity
-
delete
-
delete
-
delete
-
exists
- Throws:
MorphiumDriverException
-
exists
- Throws:
MorphiumDriverException
-
getStatistics
-
resetStatistics
public void resetStatistics() -
getStats
-
getShutDownListeners
-
addShutdownListener
-
removeShutdownListener
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
createCamelCase
-
mapReduce
public <T> List<T> mapReduce(Class<? extends T> type, String map, String reduce) throws MorphiumDriverException - Throws:
MorphiumDriverException
-
createAggregator
public <T,R> Aggregator<T,R> createAggregator(Class<? extends T> type, Class<? extends R> resultType) -
createLazyLoadedEntity
-
getWriteBufferCount
public int getWriteBufferCount() -
getBufferedWriterBufferCount
public int getBufferedWriterBufferCount() -
getAsyncWriterBufferCount
public int getAsyncWriterBufferCount() -
getWriterBufferCount
public int getWriterBufferCount() -
disableAutoValuesForThread
public void disableAutoValuesForThread() -
enableAutoValuesForThread
public void enableAutoValuesForThread() -
isAutoValuesEnabledForThread
public boolean isAutoValuesEnabledForThread() -
disableReadCacheForThread
public void disableReadCacheForThread() -
enableReadCacheForThread
public void enableReadCacheForThread() -
isReadCacheEnabledForThread
public boolean isReadCacheEnabledForThread() -
disableWriteBufferForThread
public void disableWriteBufferForThread() -
enableWriteBufferForThread
public void enableWriteBufferForThread() -
isWriteBufferEnabledForThread
public boolean isWriteBufferEnabledForThread() -
disableAsyncWritesForThread
public void disableAsyncWritesForThread() -
enableAsyncWritesForThread
public void enableAsyncWritesForThread() -
isAsyncWritesEnabledForThread
public boolean isAsyncWritesEnabledForThread() -
queueTask
-
getNumberOfAvailableThreads
public int getNumberOfAvailableThreads() -
getActiveThreads
public int getActiveThreads() -
startTransaction
public void startTransaction() -
getTransaction
-
setTransaction
-
commitTransaction
public void commitTransaction() -
abortTransaction
public void abortTransaction() -
watchAsync
-
watchAsync
-
watchAsync
-
watchAsync
-
watch
-
watch
-
watch
-
watch
-
watch
-
watchDbAsync
public <T> AtomicBoolean watchDbAsync(String dbName, boolean updateFull, List<Map<String, Object>> pipeline, ChangeStreamListener lst) -
watchDbAsync
public <T> AtomicBoolean watchDbAsync(boolean updateFull, AtomicBoolean runningFlag, ChangeStreamListener lst) -
watchDbAsync
public <T> AtomicBoolean watchDbAsync(boolean updateFull, List<Map<String, Object>> pipeline, ChangeStreamListener lst) -
watchDb
-
watchDb
-
watchDb
public <T> void watchDb(String dbName, boolean updateFull, List<Map<String, Object>> pipeline, AtomicBoolean runningFlag, ChangeStreamListener lst) -
watchDb
public <T> void watchDb(String dbName, int maxWaitTime, boolean updateFull, List<Map<String, Object>> pipeline, AtomicBoolean runningFlag, ChangeStreamListener lst) -
reset
public void reset() -
getMissingIndicesFor
- Throws:
MorphiumDriverException
-
getMissingIndicesFor
public List<IndexDescription> getMissingIndicesFor(Class<?> entity, String collection) throws MorphiumDriverException - Throws:
MorphiumDriverException
-
checkIndices
run trhough classpath, find all Entities, check indices returns a list of Entities, whos indices are missing or different -
checkCapped
-
checkIndices
public Map<Class<?>,List<IndexDescription>> checkIndices(io.github.classgraph.ClassInfoList.ClassInfoFilter filter) -
toString
-