/** * @param query * @param ops * @param <T> * @return */ public <T> UpdateResults<T> update(Query<T> query, UpdateOperations<T> ops) { return update(query, ops, false, true); }
/** * @param type * @param fields * @param <T> */ public <T> void ensureIndex(Class<T> type, IndexFieldDef... fields) { ensureIndex(type, null, fields, false, false); }
/** * @param clazz * @param <T> * @return */ public <T> Query<T> find(Class<T> clazz) { return createQuery(clazz); }
@Override public Datastore getDatabaseByName(final String name) { if(dsMap.get(name) == null) { Datastore ds = morphia.createDatastore(mClient, name); ds.ensureCaps(); ds.ensureIndexes(); dsMap.put(name, ds); } return dsMap.get(name); } }
/** * Constructor. Uses the supplied mapper and maps the supplied classes. * * @param classesToMap * @param myMapper */ public Morphia(Set<Class> classesToMap, Mapper myMapper) { this.mapper = myMapper; for (Class c : classesToMap) { map(c); } }
/** * @param entity * @param <T> * @return */ public <T> WriteResult delete(T entity) { return delete(entity, getWriteConcern(entity)); }
/** * @param entity * @param <T> * @return */ public <T> Key<T> insert(T entity) { return insert(entity, getWriteConcern(entity)); }
/** * @param entity * @param <T> * @return */ public <T> Key<T> save(T entity) { return save(entity, getWriteConcern(entity)); }
/** * @param entity * @param <T> * @return */ public <T> Key<T> merge(T entity) { return merge(entity, getWriteConcern(entity)); }
/** * @param query * @param ops * @param oldVersion indicated the old version of the Entity should be returned * @param <T> * @return */ public <T> T findAndModify(Query<T> query, UpdateOperations<T> ops, boolean oldVersion) { return findAndModify(query, ops, oldVersion, false); }
/** * @param keys * @param <T> * @return */ public <T> List<T> getByKeys(Iterable<Key<T>> keys) { return this.getByKeys((Class<T>) null, keys); }
/** * @param db * @return */ public Datastore copy(String db) { return new DatastoreImpl(mapr, mongo, db); }
/** * The underlying collection for this DAO */ public DBCollection getCollection() { return ds.getCollection(entityClazz); }
/** * Proxy to {@link #ensureIndexes(Class, boolean)} running the task in the foreground. * * @param clazz The class to index. */ public <T> void ensureIndexes(Class<T> clazz) { ensureIndexes(clazz, false); }
/** * @param clazz * @param id * @param <T> * @param <V> * @return */ public <T, V> WriteResult delete(Class<T> clazz, V id) { return delete(clazz, id, getWriteConcern(clazz)); }
/** * @param query * @param ops * @param <T> * @return */ public <T> UpdateResults<T> updateFirst(Query<T> query, UpdateOperations<T> ops) { return update(query, ops, false, false); }
/** * @param type * @param background * @param fields * @param <T> */ public <T> void ensureIndex(Class<T> type, boolean background, IndexFieldDef... fields) { ensureIndex(type, null, fields, false, false, background); }
/** * @param q * @param ops * @param <T> * @return */ public <T> T findAndModify(Query<T> q, UpdateOperations<T> ops) { return findAndModify(q, ops, false); }
/** * @param query * @param ops * @param createIfMissing * @param wc * @param <T> * @return */ public <T> UpdateResults<T> update(Query<T> query, UpdateOperations<T> ops, boolean createIfMissing, WriteConcern wc) { return update(query, ops, createIfMissing, true, wc); }
/** * @param clazz * @param name * @param defs * @param unique * @param dropDupsOnCreate * @param <T> */ public <T> void ensureIndex(Class<T> clazz, String name, IndexFieldDef[] defs, boolean unique, boolean dropDupsOnCreate) { ensureIndex(clazz, name, defs, unique, dropDupsOnCreate, false); }