本文整理了Java中org.springframework.data.mongodb.core.query.Update.getUpdateObject()
方法的一些代码示例,展示了Update.getUpdateObject()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Update.getUpdateObject()
方法的具体详情如下:
包路径:org.springframework.data.mongodb.core.query.Update
类名称:Update
方法名:getUpdateObject
暂无
代码示例来源:origin: spring-projects/spring-data-mongodb
@Override
public Document getUpdateObject() {
return delegate.getUpdateObject();
}
代码示例来源:origin: spring-projects/spring-data-mongodb
@Override
public int hashCode() {
return Objects.hash(getUpdateObject(), isolated);
}
代码示例来源:origin: spring-projects/spring-data-mongodb
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
Update that = (Update) obj;
if (this.isolated != that.isolated) {
return false;
}
return Objects.equals(this.getUpdateObject(), that.getUpdateObject());
}
代码示例来源:origin: spring-projects/spring-data-mongodb
/**
* Performs update and upsert bulk operations.
*
* @param query the {@link Query} to determine documents to update.
* @param update the {@link Update} to perform, must not be {@literal null}.
* @param upsert whether to upsert.
* @param multi whether to issue a multi-update.
* @return the {@link BulkOperations} with the update registered.
*/
private BulkOperations update(Query query, Update update, boolean upsert, boolean multi) {
Assert.notNull(query, "Query must not be null!");
Assert.notNull(update, "Update must not be null!");
UpdateOptions options = new UpdateOptions();
options.upsert(upsert);
query.getCollation().map(Collation::toMongoCollation).ifPresent(options::collation);
if (multi) {
models.add(new UpdateManyModel<>(query.getQueryObject(), update.getUpdateObject(), options));
} else {
models.add(new UpdateOneModel<>(query.getQueryObject(), update.getUpdateObject(), options));
}
return this;
}
代码示例来源:origin: spring-projects/spring-data-mongodb
@Override
public String toString() {
Document doc = getUpdateObject();
if (isIsolated()) {
doc.append("$isolated", 1);
}
return SerializationUtils.serializeToJsonSafely(doc);
}
代码示例来源:origin: spring-projects/spring-data-mongodb
protected <T> Mono<T> doFindAndModify(String collectionName, Document query, Document fields, Document sort,
Class<T> entityClass, Update update, FindAndModifyOptions options) {
MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(entityClass);
return Mono.defer(() -> {
increaseVersionForUpdateIfNecessary(entity, update);
Document mappedQuery = queryMapper.getMappedObject(query, entity);
Document mappedUpdate = updateMapper.getMappedObject(update.getUpdateObject(), entity);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(String.format(
"findAndModify using query: %s fields: %s sort: %s for class: %s and update: %s " + "in collection: %s",
serializeToJsonSafely(mappedQuery), fields, sort, entityClass, serializeToJsonSafely(mappedUpdate),
collectionName));
}
return executeFindOneInternal(new FindAndModifyCallback(mappedQuery, fields, sort, mappedUpdate, options),
new ReadDocumentCallback<>(this.mongoConverter, entityClass, collectionName), collectionName);
});
}
代码示例来源:origin: spring-projects/spring-data-mongodb
protected <T> T doFindAndModify(String collectionName, Document query, Document fields, Document sort,
Class<T> entityClass, Update update, @Nullable FindAndModifyOptions options) {
EntityReader<? super T, Bson> readerToUse = this.mongoConverter;
if (options == null) {
options = new FindAndModifyOptions();
}
MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(entityClass);
increaseVersionForUpdateIfNecessary(entity, update);
Document mappedQuery = queryMapper.getMappedObject(query, entity);
Document mappedUpdate = updateMapper.getMappedObject(update.getUpdateObject(), entity);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
"findAndModify using query: {} fields: {} sort: {} for class: {} and update: {} " + "in collection: {}",
serializeToJsonSafely(mappedQuery), fields, sort, entityClass, serializeToJsonSafely(mappedUpdate),
collectionName);
}
return executeFindOneInternal(new FindAndModifyCallback(mappedQuery, fields, sort, mappedUpdate, options),
new ReadDocumentCallback<>(readerToUse, entityClass, collectionName), collectionName);
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
@Override
public Document getUpdateObject() {
return delegate.getUpdateObject();
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
@Override
public int hashCode() {
return Objects.hash(getUpdateObject(), isolated);
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
Update that = (Update) obj;
if (this.isolated != that.isolated) {
return false;
}
return Objects.equals(this.getUpdateObject(), that.getUpdateObject());
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
/**
* Performs update and upsert bulk operations.
*
* @param query the {@link Query} to determine documents to update.
* @param update the {@link Update} to perform, must not be {@literal null}.
* @param upsert whether to upsert.
* @param multi whether to issue a multi-update.
* @return the {@link BulkOperations} with the update registered.
*/
private BulkOperations update(Query query, Update update, boolean upsert, boolean multi) {
Assert.notNull(query, "Query must not be null!");
Assert.notNull(update, "Update must not be null!");
UpdateOptions options = new UpdateOptions();
options.upsert(upsert);
query.getCollation().map(Collation::toMongoCollation).ifPresent(options::collation);
if (multi) {
models.add(new UpdateManyModel<>(query.getQueryObject(), update.getUpdateObject(), options));
} else {
models.add(new UpdateOneModel<>(query.getQueryObject(), update.getUpdateObject(), options));
}
return this;
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
@Override
public String toString() {
Document doc = getUpdateObject();
if (isIsolated()) {
doc.append("$isolated", 1);
}
return SerializationUtils.serializeToJsonSafely(doc);
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
protected <T> Mono<T> doFindAndModify(String collectionName, Document query, Document fields, Document sort,
Class<T> entityClass, Update update, FindAndModifyOptions options) {
MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(entityClass);
return Mono.defer(() -> {
increaseVersionForUpdateIfNecessary(entity, update);
Document mappedQuery = queryMapper.getMappedObject(query, entity);
Document mappedUpdate = updateMapper.getMappedObject(update.getUpdateObject(), entity);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(String.format(
"findAndModify using query: %s fields: %s sort: %s for class: %s and update: %s " + "in collection: %s",
serializeToJsonSafely(mappedQuery), fields, sort, entityClass, serializeToJsonSafely(mappedUpdate),
collectionName));
}
return executeFindOneInternal(new FindAndModifyCallback(mappedQuery, fields, sort, mappedUpdate, options),
new ReadDocumentCallback<>(this.mongoConverter, entityClass, collectionName), collectionName);
});
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
protected <T> T doFindAndModify(String collectionName, Document query, Document fields, Document sort,
Class<T> entityClass, Update update, @Nullable FindAndModifyOptions options) {
EntityReader<? super T, Bson> readerToUse = this.mongoConverter;
if (options == null) {
options = new FindAndModifyOptions();
}
MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(entityClass);
increaseVersionForUpdateIfNecessary(entity, update);
Document mappedQuery = queryMapper.getMappedObject(query, entity);
Document mappedUpdate = updateMapper.getMappedObject(update.getUpdateObject(), entity);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
"findAndModify using query: {} fields: {} sort: {} for class: {} and update: {} " + "in collection: {}",
serializeToJsonSafely(mappedQuery), fields, sort, entityClass, serializeToJsonSafely(mappedUpdate),
collectionName);
}
return executeFindOneInternal(new FindAndModifyCallback(mappedQuery, fields, sort, mappedUpdate, options),
new ReadDocumentCallback<>(readerToUse, entityClass, collectionName), collectionName);
}
代码示例来源:origin: pl.edu.icm.polindex/polindex-tools
@Override
public int removeTag(RecordQuery recordQuery, Tag tag) {
Update update = new Update().pull(F_TAGS, tag.getTag());
logger.debug("executing mongo update: {} on records selected by: {}", update.getUpdateObject(), recordQuery.getQuery());
WriteResult res = mongoTemplate.updateMulti(recordQuery.getQuery(), update, collectionName);
logger.debug("removed tag " + tag + " from " + res.getN() + " records");
return res.getN();
}
代码示例来源:origin: pl.edu.icm.polindex/polindex-tools
@Override
public int addTag(RecordQuery recordQuery, Tag tag) {
Update update = new Update().push(F_TAGS, tag.getTag());
logger.debug("executing mongo update: {} on records selected by: {}", update.getUpdateObject(), recordQuery.getQuery());
WriteResult res = mongoTemplate.updateMulti(recordQuery.getQuery(), update, collectionName);
logger.debug("added tag " + tag + " to " + res.getN() + " records");
return res.getN();
}
内容来源于网络,如有侵权,请联系作者删除!