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

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

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

Criteria.is介绍

[英]Creates a criterion using equality
[中]使用相等创建标准

代码示例

代码示例来源:origin: ityouknow/spring-boot-examples

/**
 * 根据用户名查询对象
 * @param userName
 * @return
 */
@Override
public UserEntity findUserByUserName(String userName) {
  Query query=new Query(Criteria.where("userName").is(userName));
  UserEntity user =  mongoTemplate.findOne(query , UserEntity.class);
  return user;
}

代码示例来源:origin: ityouknow/spring-boot-examples

/**
   * 删除对象
   * @param id
   */
  @Override
  public void deleteUserById(Long id) {
    Query query=new Query(Criteria.where("id").is(id));
    mongoTemplate.remove(query,UserEntity.class);
  }
}

代码示例来源:origin: kaaproject/kaa

@Override
public Optional<MongoEndpointRegistration> findByEndpointId(String endpointId) {
 LOG.debug("Searching for endpoint registration by endpoint ID [{}]", endpointId);
 Query query = Query.query(
   Criteria.where(MongoModelConstants.EP_REGISTRATION_ENDPOINT_ID)
     .is(endpointId));
 return Optional.ofNullable(this.findOne(query));
}

代码示例来源:origin: kaaproject/kaa

@Override
public Optional<MongoEndpointRegistration> findByCredentialsId(String credentialsId) {
 LOG.debug("Searching for endpoint registration by credentials ID [{}]", credentialsId);
 Query query = Query.query(
   Criteria.where(MongoModelConstants.EP_REGISTRATION_CREDENTIALS_ID)
     .is(credentialsId));
 return Optional.ofNullable(this.findOne(query));
}

代码示例来源:origin: kaaproject/kaa

@Override
public void removeByAppId(String appId) {
 LOG.debug("Remove endpoint profile by application id [{}] ", appId);
 remove(query(where(EP_APPLICATION_ID).is(appId)));
}

代码示例来源: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/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/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/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: kaaproject/kaa

@Override
public List<MongoEndpointNotification> findNotificationsByKeyHash(final byte[] keyHash) {
 LOG.debug("Find unicast notifications by endpoint key hash [{}] ", keyHash);
 DBObject dbObject = query(where(EP_ENDPOINT_KEY_HASH).is(keyHash)).getQueryObject();
 DBCursor cursor = mongoTemplate.getDb().getCollection(getCollectionName()).find(dbObject);
 List<MongoEndpointNotification> endpointNotifications = new ArrayList<>();
 while (cursor.hasNext()) {
  endpointNotifications.add(mongoTemplate.getConverter()
    .read(MongoEndpointNotification.class, cursor.next()));
 }
 return endpointNotifications;
}

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

private Mono<Process> finish(ReactiveMongoOperations operations, Process process) {
  return operations.update(Process.class).matching(Query.query(Criteria.where("id").is(process.getId())))
      .apply(Update.update("state", State.DONE).inc("transitionCount", 1)).first() //
      .then(Mono.just(process));
}

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

Mono<Process> start(ReactiveMongoOperations operations, Process process) {
  return operations.update(Process.class).matching(Query.query(Criteria.where("id").is(process.getId())))
      .apply(Update.update("state", State.ACTIVE).inc("transitionCount", 1)).first() //
      .then(Mono.just(process));
}

代码示例来源: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;
}

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

private void finish(Process process) {
  template.update(Process.class).matching(Query.query(Criteria.where("id").is(process.getId())))
      .apply(Update.update("state", State.DONE).inc("transitionCount", 1)).first();
}

代码示例来源:origin: ityouknow/spring-boot-examples

/**
 * 更新对象
 * @param user
 */
@Override
public int updateUser(UserEntity user) {
  Query query=new Query(Criteria.where("id").is(user.getId()));
  Update update= new Update().set("userName", user.getUserName()).set("passWord", user.getPassWord());
  //更新查询返回结果集的第一条
  WriteResult result =mongoTemplate.updateFirst(query,update,UserEntity.class);
  //更新查询返回结果集的所有
  // mongoTemplate.updateMulti(query,update,UserEntity.class);
  if(result!=null)
    return result.getN();
  else
    return 0;
}

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

void start(Process process) {
  template.update(Process.class).matching(Query.query(Criteria.where("id").is(process.getId())))
      .apply(Update.update("state", State.ACTIVE).inc("transitionCount", 1)).first();
}

相关文章