本文整理匯總了Java中org.springframework.data.mongodb.core.query.Query.addCriteria方法的典型用法代碼示例。如果您正苦於以下問題:Java Query.addCriteria方法的具體用法?Java Query.addCriteria怎麽用?Java Query.addCriteria使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.data.mongodb.core.query.Query
的用法示例。
在下文中一共展示了Query.addCriteria方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildQuery
import org.springframework.data.mongodb.core.query.Query; //導入方法依賴的package包/類
private Query buildQuery(AuthEventQueryRequest request) {
Query query = new Query();
if (!StringUtils.isEmpty(request.getRealm())) {
query.addCriteria(Criteria.where("realm").is(request.getRealm()));
}
if (!StringUtils.isEmpty(request.getUsername())) {
query.addCriteria(Criteria.where("username").regex(request.getUsername()));
}
if (request.getBeginDate() != null && request.getEndDate() != null) {
query.addCriteria(new Criteria().andOperator(Criteria.where("loginAt").gte(request.getBeginDate()),
Criteria.where("loginAt").lte(request.getEndDate())));
}
else if (request.getBeginDate() != null) {
query.addCriteria(Criteria.where("loginAt").gte(request.getBeginDate()));
}
else if (request.getEndDate() != null) {
query.addCriteria(Criteria.where("loginAt").lte(request.getEndDate()));
}
Boolean succeed = request.getSucceed();
if (succeed != null) {
query.addCriteria(Criteria.where("succeed").is(succeed.booleanValue()));
}
return query;
}
示例2: updateNotebook
import org.springframework.data.mongodb.core.query.Query; //導入方法依賴的package包/類
public void updateNotebook(Notebook notebook){
Query query = new Query();
query.addCriteria(new Criteria("NotebookId").is(notebook.getNotebookId()));
Update update = new Update();
update.set("title", notebook.getTitle());
update.set("description", notebook.getDescription());
update.set("creator", notebook.getCreator());
update.set("owner", notebook.getOwner());
update.set("star", notebook.getStar());
update.set("collected", notebook.getCollected());
update.set("clickCount", notebook.getClickCount());
update.set("collaborators", notebook.getCollaborators());
update.set("contributors", notebook.getContributors());
update.set("notes", notebook.getNotes());
update.set("createTime", notebook.getCreateTime());
update.set("cover", notebook.getCover());
update.set("tags", notebook.getTags());
update.set("starers", notebook.getStarers());
mongoTemplate.updateFirst(query, update, Notebook.class,"Notebook");
}
示例3: get
import org.springframework.data.mongodb.core.query.Query; //導入方法依賴的package包/類
@Override
public Set<MultifactorAuthenticationTrustRecord> get(final String principal) {
final Query query = new Query();
query.addCriteria(Criteria.where("principal").is(principal));
final List<MultifactorAuthenticationTrustRecord> results =
this.mongoTemplate.find(query, MultifactorAuthenticationTrustRecord.class, this.collectionName);
return new HashSet<>(results);
}
示例4: findOneByRidAndCid
import org.springframework.data.mongodb.core.query.Query; //導入方法依賴的package包/類
@Override
public VirtualObject findOneByRidAndCid(Integer rid, Short cid) {
Query query = new Query();
query.addCriteria(Criteria.where("rid").is(rid).andOperator(Criteria.where("eClassId").is(cid)));
return findOne(query);
}
示例5: remove
import org.springframework.data.mongodb.core.query.Query; //導入方法依賴的package包/類
/**
* 刪除
* @param pd
* @param collectionName
*/
public void remove(PageData pd, String collectionName) {
Query query = new Query();
for (Object key : pd.keySet()) {
query.addCriteria(Criteria.where((String) key).in(pd.getString(key)));
}
mongoTemplate.remove(query, collectionName);
}
示例6: findHotStoriesOfGroup
import org.springframework.data.mongodb.core.query.Query; //導入方法依賴的package包/類
@Override
public List<Story> findHotStoriesOfGroup(String groupId) {
Query query = new Query();
query.with(new Sort(Sort.Direction.DESC, "this.comments.length"));
query.addCriteria(Criteria.where("groupId").is(groupId));
return mongoTemplate.find(query, Story.class);
}
示例7: updateStatus
import org.springframework.data.mongodb.core.query.Query; //導入方法依賴的package包/類
/**
* 更新補償數據狀態
*
* @param id 事務id
* @param status 狀態
* @return rows 1 成功 0 失敗
*/
@Override
public int updateStatus(String id, Integer status) {
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 TccRuntimeException("更新數據異常!");
}
return 1;
}
示例8: updateProject
import org.springframework.data.mongodb.core.query.Query; //導入方法依賴的package包/類
@Override
public void updateProject(Project project) {
Query query = new Query();
query.addCriteria(Criteria.where("pid").is(project.getPid()));
Update update = new Update();
update.set("author", project.getAuthor())
.set("title", project.getTitle())
.set("description", project.getDescription())
.set("stars", project.getStars())
.set("picUrl", project.getPicUrl());
mongoTemplate.findAndModify(query, update, Project.class);
}
示例9: findNewStoriesOfGroup
import org.springframework.data.mongodb.core.query.Query; //導入方法依賴的package包/類
@Override
public List<Story> findNewStoriesOfGroup(String groupId) {
Query query = new Query();
query.with(new Sort(Sort.Direction.DESC, "postDate"));
query.addCriteria(Criteria.where("groupId").is(groupId));
return mongoTemplate.find(query, Story.class);
}
示例10: deleteVerify
import org.springframework.data.mongodb.core.query.Query; //導入方法依賴的package包/類
public void deleteVerify(Verify verify){
Query query = new Query();
query.addCriteria(new Criteria("verifyId").is(verify.getVerifyId()));
mongoTemplate.findAndRemove(query, Verify.class,"Verify");
}
示例11: findNewStoriesOfUser
import org.springframework.data.mongodb.core.query.Query; //導入方法依賴的package包/類
@Override
public List<Story> findNewStoriesOfUser(String userId) {
Query query = new Query();
query.with(new Sort(Sort.Direction.DESC, "postDate"));
query.addCriteria(Criteria.where("userId").is(userId));
return mongoTemplate.find(query, Story.class);
}
示例12: deleteNote
import org.springframework.data.mongodb.core.query.Query; //導入方法依賴的package包/類
public void deleteNote(Note note){
Query query = new Query();
query.addCriteria(new Criteria("noteId").is(note.getNoteId()));
mongoTemplate.findAndRemove(query, Note.class,"Note");
}
示例13: deleteOutputTemplate
import org.springframework.data.mongodb.core.query.Query; //導入方法依賴的package包/類
@Override
public void deleteOutputTemplate(Long otid) {
Query query = new Query();
query.addCriteria(Criteria.where("otid").is(otid));
mongoTemplate.remove(query, OutputTemplate.class);
}
示例14: deleteLetter
import org.springframework.data.mongodb.core.query.Query; //導入方法依賴的package包/類
public void deleteLetter(Letter letter){
Query query = new Query();
query.addCriteria(new Criteria("letterId").is(letter.getLetterId()));
mongoTemplate.findAndRemove(query, Letter.class,"Letter");
}
示例15: getEventsOfType
import org.springframework.data.mongodb.core.query.Query; //導入方法依賴的package包/類
@Override
public Collection<CasEvent> getEventsOfType(final String type) {
final Query query = new Query();
query.addCriteria(Criteria.where(TYPE_PARAM).is(type));
return this.mongoTemplate.find(query, CasEvent.class, this.collectionName);
}