org.springframework.data.mongodb.core.query.Criteria.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(263)

本文整理了Java中org.springframework.data.mongodb.core.query.Criteria.<init>()方法的一些代码示例,展示了Criteria.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Criteria.<init>()方法的具体详情如下:
包路径:org.springframework.data.mongodb.core.query.Criteria
类名称:Criteria
方法名:<init>

Criteria.<init>介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-data-mongodb

/**
 * Static factory method to create a Criteria using the provided key
 *
 * @param key
 * @return
 */
public static Criteria where(String key) {
  return new Criteria(key);
}

代码示例来源:origin: spring-projects/spring-data-mongodb

/**
 * Static factory method to create a Criteria using the provided key
 *
 * @return
 */
public Criteria and(String key) {
  return new Criteria(this.criteriaChain, key);
}

代码示例来源:origin: spring-projects/spring-data-mongodb

@Override
protected Criteria or(Criteria base, Criteria criteria) {
  Criteria result = new Criteria();
  return result.orOperator(base, criteria);
}

代码示例来源:origin: spring-projects/spring-data-mongodb

/**
 * Static factory method to create a {@link Criteria} matching an example object.
 *
 * @param example must not be {@literal null}.
 * @return
 * @see Criteria#alike(Example)
 * @since 1.8
 */
public static Criteria byExample(Example<?> example) {
  return new Criteria().alike(example);
}

代码示例来源:origin: spring-projects/spring-data-mongodb

public Query getByIdInQuery(Collection<?> entities) {
  MultiValueMap<String, Object> byIds = new LinkedMultiValueMap<>();
  entities.stream() //
      .map(this::forEntity) //
      .forEach(it -> byIds.add(it.getIdFieldName(), it.getId()));
  Criteria[] criterias = byIds.entrySet().stream() //
      .map(it -> Criteria.where(it.getKey()).in(it.getValue())) //
      .toArray(Criteria[]::new);
  return new Query(criterias.length == 1 ? criterias[0] : new Criteria().orOperator(criterias));
}

代码示例来源:origin: spring-projects/spring-data-mongodb

@Override
public <S extends T> Mono<Long> count(Example<S> example) {
  Assert.notNull(example, "Sample must not be null!");
  Query q = new Query(new Criteria().alike(example));
  return mongoOperations.count(q, example.getProbeType(), entityInformation.getCollectionName());
}

代码示例来源:origin: spring-projects/spring-data-mongodb

@Override
public <S extends T> long count(Example<S> example) {
  Assert.notNull(example, "Sample must not be null!");
  Query q = new Query(new Criteria().alike(example));
  return mongoOperations.count(q, example.getProbeType(), entityInformation.getCollectionName());
}

代码示例来源:origin: spring-projects/spring-data-mongodb

@Override
public <S extends T> boolean exists(Example<S> example) {
  Assert.notNull(example, "Sample must not be null!");
  Query q = new Query(new Criteria().alike(example));
  return mongoOperations.exists(q, example.getProbeType(), entityInformation.getCollectionName());
}

代码示例来源:origin: spring-projects/spring-data-mongodb

@Override
public <S extends T> List<S> findAll(Example<S> example, Sort sort) {
  Assert.notNull(example, "Sample must not be null!");
  Assert.notNull(sort, "Sort must not be null!");
  Query q = new Query(new Criteria().alike(example)).with(sort);
  return mongoOperations.find(q, example.getProbeType(), entityInformation.getCollectionName());
}

代码示例来源:origin: yu199195/hmily

@Override
public Boolean batchRemove(final List<String> ids, final String applicationName) {
  if (CollectionUtils.isEmpty(ids) || StringUtils.isBlank(applicationName)) {
    return Boolean.FALSE;
  }
  final String mongoTableName = RepositoryPathUtils.buildMongoTableName(applicationName);
  ids.forEach(id -> {
    Query query = new Query();
    query.addCriteria(new Criteria("transId").is(id));
    mongoTemplate.remove(query, mongoTableName);
  });
  return Boolean.TRUE;
}

代码示例来源:origin: yu199195/myth

@Override
public Boolean batchRemove(final List<String> ids, final String appName) {
  if (CollectionUtils.isEmpty(ids) || StringUtils.isBlank(appName)) {
    return Boolean.FALSE;
  }
  final String mongoTableName = RepositoryPathUtils.buildMongoTableName(appName);
  ids.forEach(id -> {
    Query query = new Query();
    query.addCriteria(new Criteria("transId").is(id));
    mongoTemplate.remove(query, mongoTableName);
  });
  return Boolean.TRUE;
}

代码示例来源:origin: spring-projects/spring-data-mongodb

@Override
public Iterable<T> findAllById(Iterable<ID> ids) {
  return findAll(new Query(new Criteria(entityInformation.getIdAttribute())
      .in(Streamable.of(ids).stream().collect(StreamUtils.toUnmodifiableList()))));
}

代码示例来源:origin: yu199195/hmily

@Override
public HmilyTransaction findById(final String id) {
  Query query = new Query();
  query.addCriteria(new Criteria("transId").is(id));
  MongoAdapter cache = template.findOne(query, MongoAdapter.class, collectionName);
  return buildByCache(Objects.requireNonNull(cache));
}

代码示例来源:origin: yu199195/myth

@Override
public int remove(final String transId) {
  Query query = new Query();
  query.addCriteria(new Criteria("transId").is(transId));
  template.remove(query, collectionName);
  return CommonConstant.SUCCESS;
}

代码示例来源:origin: yu199195/hmily

@Override
public int remove(final String id) {
  AssertUtils.notNull(id);
  Query query = new Query();
  query.addCriteria(new Criteria("transId").is(id));
  template.remove(query, collectionName);
  return ROWS;
}

代码示例来源:origin: yu199195/Raincat

@Override
public int remove(final String id) {
  Assert.notNull(id);
  Query query = new Query();
  query.addCriteria(new Criteria("transId").is(id));
  template.remove(query, collectionName);
  return ROWS;
}

代码示例来源:origin: yu199195/Raincat

@Override
public TransactionRecover findById(final String id) {
  Query query = new Query();
  query.addCriteria(new Criteria("transId").is(id));
  MongoAdapter cache = template.findOne(query, MongoAdapter.class, collectionName);
  return buildByCache(cache);
}

代码示例来源:origin: yu199195/myth

@Override
public MythTransaction findByTransId(final String transId) {
  Query query = new Query();
  query.addCriteria(new Criteria("transId").is(transId));
  MongoAdapter cache = template.findOne(query, MongoAdapter.class, collectionName);
  return buildByCache(cache);
}

代码示例来源:origin: yu199195/hmily

@Override
public int updateStatus(final String id, final Integer status) {
  Query query = new Query();
  query.addCriteria(new Criteria("transId").is(id));
  Update update = new Update();
  update.set("status", status);
  final UpdateResult updateResult = template.updateFirst(query, update, MongoAdapter.class, collectionName);
  if (updateResult.getModifiedCount() <= 0) {
    throw new HmilyRuntimeException("update data exception!");
  }
  return ROWS;
}

代码示例来源:origin: yu199195/myth

@Override
public int updateStatus(final String id, final Integer status) throws MythRuntimeException {
  Query query = new Query();
  query.addCriteria(new Criteria("transId").is(id));
  Update update = new Update();
  update.set("status", status);
  final WriteResult writeResult = template.updateFirst(query, update, MongoAdapter.class, collectionName);
  if (writeResult.getN() <= 0) {
    throw new MythRuntimeException(ERROR);
  }
  return CommonConstant.SUCCESS;
}

相关文章