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

x33g5p2x  于2022-01-28 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(387)

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

Query.<init>介绍

[英]Creates a new Query using the given CriteriaDefinition.
[中]使用给定的准则定义创建新查询。

代码示例

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

@Override
public List<HmilyTransaction> listAllByDelay(final Date date) {
  Query query = new Query();
  query.addCriteria(Criteria.where("lastTime").lt(date));
  final List<MongoAdapter> mongoBeans =
      template.find(query, MongoAdapter.class, collectionName);
  if (CollectionUtils.isNotEmpty(mongoBeans)) {
    return mongoBeans.stream().map(this::buildByCache).collect(Collectors.toList());
  }
  return Collections.emptyList();
}

代码示例来源: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: 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: 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: roncoo/spring-boot-demo

public void deleteById(int id) {
  Criteria criteria = Criteria.where("id").in(id);
  Query query = new Query(criteria);
  mongoTemplate.remove(query, RoncooUser.class);
}

代码示例来源:origin: roncoo/spring-boot-demo

public void deleteById(int id) {
  Criteria criteria = Criteria.where("id").in(id);
  Query query = new Query(criteria);
  mongoTemplate.remove(query, RoncooUser.class);
}

代码示例来源:origin: roncoo/spring-boot-demo

public void deleteById(int id) {
  Criteria criteria = Criteria.where("id").in(id);
  Query query = new Query(criteria);
  mongoTemplate.remove(query, RoncooUser.class);
}

代码示例来源:origin: roncoo/spring-boot-demo

public void deleteById(int id) {
  Criteria criteria = Criteria.where("id").in(id);
  Query query = new Query(criteria);
  mongoTemplate.remove(query, RoncooUser.class);
}

代码示例来源:origin: roncoo/spring-boot-demo

public RoncooUser selectById(int id) {
    Criteria criteria = Criteria.where("id").in(id);
    Query query = new Query(criteria);
    return mongoTemplate.findOne(query, RoncooUser.class);
  }
}

代码示例来源:origin: roncoo/spring-boot-demo

public void deleteById(int id) {
  Criteria criteria = Criteria.where("id").in(id);
  Query query = new Query(criteria);
  mongoTemplate.remove(query, RoncooUser.class);
}

代码示例来源:origin: roncoo/spring-boot-demo

public RoncooUser selectById(int id) {
    Criteria criteria = Criteria.where("id").in(id);
    Query query = new Query(criteria);
    return mongoTemplate.findOne(query, RoncooUser.class);
  }
}

代码示例来源: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/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/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: 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: roncoo/spring-boot-demo

public void updateById(RoncooUser roncooUser) {
  Criteria criteria = Criteria.where("id").in(roncooUser.getId());
  Query query = new Query(criteria);
  Update update = new Update();
  update.set("name", roncooUser.getName());
  update.set("createTime", roncooUser.getCreateTime());
  mongoTemplate.updateMulti(query, update, RoncooUser.class);
}

代码示例来源:origin: roncoo/spring-boot-demo

public void updateById(RoncooUser roncooUser) {
  Criteria criteria = Criteria.where("id").in(roncooUser.getId());
  Query query = new Query(criteria);
  Update update = new Update();
  update.set("name", roncooUser.getName());
  update.set("createTime", roncooUser.getCreateTime());
  mongoTemplate.updateMulti(query, update, RoncooUser.class);
}

代码示例来源:origin: roncoo/spring-boot-demo

public void updateById(RoncooUser roncooUser) {
  Criteria criteria = Criteria.where("id").in(roncooUser.getId());
  Query query = new Query(criteria);
  Update update = new Update();
  update.set("name", roncooUser.getName());
  update.set("createTime", roncooUser.getCreateTime());
  mongoTemplate.updateMulti(query, update, RoncooUser.class);
}

代码示例来源:origin: roncoo/spring-boot-demo

public void updateById(RoncooUser roncooUser) {
  Criteria criteria = Criteria.where("id").in(roncooUser.getId());
  Query query = new Query(criteria);
  Update update = new Update();
  update.set("name", roncooUser.getName());
  update.set("createTime", roncooUser.getCreateTime());
  mongoTemplate.updateMulti(query, update, RoncooUser.class);
}

代码示例来源:origin: roncoo/spring-boot-demo

public void updateById(RoncooUser roncooUser) {
  Criteria criteria = Criteria.where("id").in(roncooUser.getId());
  Query query = new Query(criteria);
  Update update = new Update();
  update.set("name", roncooUser.getName());
  update.set("createTime", roncooUser.getCreateTime());
  mongoTemplate.updateMulti(query, update, RoncooUser.class);
}

相关文章