本文整理了Java中org.springframework.data.mongodb.core.query.Criteria.where()
方法的一些代码示例,展示了Criteria.where()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Criteria.where()
方法的具体详情如下:
包路径:org.springframework.data.mongodb.core.query.Criteria
类名称:Criteria
方法名:where
[英]Static factory method to create a Criteria using the provided key
[中]使用提供的键创建条件的静态工厂方法
代码示例来源: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 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: 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 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: 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: 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();
}
代码示例来源: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);
}
内容来源于网络,如有侵权,请联系作者删除!