當前位置: 首頁>>代碼示例>>Java>>正文


Java Query.addCriteria方法代碼示例

本文整理匯總了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;
}
 
開發者ID:melthaw,項目名稱:spring-backend-boilerplate,代碼行數:30,代碼來源:AuthEventRepositoryImpl.java

示例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");
}
 
開發者ID:qinjr,項目名稱:TeamNote,代碼行數:21,代碼來源:NotebookDaoImpl.java

示例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);
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:9,代碼來源:MongoDbMultifactorAuthenticationTrustStorage.java

示例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);
}
 
開發者ID:shenan4321,項目名稱:BIMplatform,代碼行數:9,代碼來源:VirtualObjectDaoImpl.java

示例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);
}
 
開發者ID:noseparte,項目名稱:Spring-Boot-Server,代碼行數:13,代碼來源:PushMongoUtil.java

示例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);
}
 
開發者ID:nicolasmanic,項目名稱:Facegram,代碼行數:9,代碼來源:StoryRepositoryImpl.java

示例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;
}
 
開發者ID:yu199195,項目名稱:happylifeplat-tcc,代碼行數:20,代碼來源:MongoCoordinatorRepository.java

示例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);
}
 
開發者ID:shenan4321,項目名稱:BIMplatform,代碼行數:13,代碼來源:ProjectDaoImpl.java

示例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);
}
 
開發者ID:nicolasmanic,項目名稱:Facegram,代碼行數:9,代碼來源:StoryRepositoryImpl.java

示例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");
}
 
開發者ID:qinjr,項目名稱:TeamNote,代碼行數:6,代碼來源:VerifyDaoImpl.java

示例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);

}
 
開發者ID:nicolasmanic,項目名稱:Facegram,代碼行數:11,代碼來源:StoryRepositoryImpl.java

示例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");
}
 
開發者ID:qinjr,項目名稱:TeamNote,代碼行數:6,代碼來源:NoteDaoImpl.java

示例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);
}
 
開發者ID:shenan4321,項目名稱:BIMplatform,代碼行數:7,代碼來源:OutputTemplateDaoImpl.java

示例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");
}
 
開發者ID:qinjr,項目名稱:TeamNote,代碼行數:6,代碼來源:LetterDaoImpl.java

示例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);
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:7,代碼來源:MongoDbCasEventRepository.java


注:本文中的org.springframework.data.mongodb.core.query.Query.addCriteria方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。