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

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

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

Query.query介绍

[英]Static factory method to create a Query using the provided CriteriaDefinition.
[中]使用提供的标准定义创建查询的静态工厂方法。

代码示例

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

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

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

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

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

  1. @Override
  2. public void removeNotificationsByAppId(final String appId) {
  3. LOG.debug("Remove unicast notifications by application id [{}] ", appId);
  4. remove(query(where(EP_NF_APPLICATION_ID).is(appId)));
  5. }

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

  1. @Override
  2. public List<MongoEndpointProfile> findByEndpointUserId(String endpointUserId) {
  3. LOG.debug("Find endpoint profiles by endpoint user id [{}] ", endpointUserId);
  4. return find(query(where(EP_USER_ID).is(endpointUserId)));
  5. }

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

  1. @Override
  2. public void removeByEndpointId(String endpointId) {
  3. LOG.debug("Removing endpoint registration by endpoint ID [{}]", endpointId);
  4. Query query = Query.query(
  5. Criteria.where(MongoModelConstants.EP_REGISTRATION_ENDPOINT_ID)
  6. .is(endpointId));
  7. this.remove(query);
  8. }
  9. }

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

  1. @Override
  2. public void removeByHash(byte[] hash) {
  3. LOG.debug("Remove topic list entry by hash [{}] ", hash);
  4. remove(query(where(ID).is(hash)));
  5. }
  6. }

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

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

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

  1. @Override
  2. public void removeNotificationsByKeyHash(final byte[] keyHash) {
  3. LOG.debug("Remove unicast notifications by endpoint key hash [{}] ", keyHash);
  4. mongoTemplate.remove(query(where(EP_ENDPOINT_KEY_HASH).is(keyHash)), getCollectionName());
  5. }

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

  1. @Override
  2. public Optional<MongoCredentials> find(String applicationId, String credentialsId) {
  3. LOG.debug("Searching for credentials by application ID [{}] and credentials ID [{}]",
  4. applicationId, credentialsId);
  5. Query query = Query.query(Criteria.where(MongoModelConstants.CREDENTIALS_ID)
  6. .is(credentialsId)
  7. .and(MongoModelConstants.APPLICATION_ID)
  8. .is(applicationId));
  9. return Optional.ofNullable(this.findOne(query));
  10. }

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

  1. @Override
  2. public void removeByExternalIdAndTenantId(String externalId, String tenantId) {
  3. LOG.debug("Remove user by external uid [{}] and tenant id [{}] ", externalId, tenantId);
  4. remove(query(where(EP_USER_EXTERNAL_ID)
  5. .is(externalId)
  6. .and(EP_USER_TENANT_ID)
  7. .is(tenantId)));
  8. }

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

  1. @Override
  2. public MongoEndpointProfile findEndpointIdByKeyHash(byte[] endpointKeyHash) {
  3. LOG.debug("Get count of endpoint profiles by endpoint key hash [{}] ", endpointKeyHash);
  4. Query query = query(where(EP_ENDPOINT_KEY_HASH).is(endpointKeyHash));
  5. query.fields().include(ID);
  6. return findOne(query);
  7. }

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

  1. @Override
  2. public MongoEndpointUser findByExternalIdAndTenantId(String externalId, String tenantId) {
  3. LOG.debug("Find user by external uid [{}] and tenant id [{}] ", externalId, tenantId);
  4. return findOne(query(where(EP_USER_EXTERNAL_ID)
  5. .is(externalId).and(EP_USER_TENANT_ID)
  6. .is(tenantId)));
  7. }

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

  1. @Override
  2. public void removeByEndpointKeyHashAndConfigurationVersion(byte[] endpointKeyHash, Integer confSchemaVersion) {
  3. LOG.debug("Remove endpoint specific configuration by endpoint key hash [{}] ", endpointKeyHash);
  4. mongoTemplate.remove(
  5. query(where(EP_SPECIFIC_CONFIGURATION_KEY_HASH).is(endpointKeyHash)
  6. .and(EP_CONFIGURATION_VERSION).is(confSchemaVersion)), getCollectionName());
  7. }

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

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

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

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

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

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

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

  1. @Override
  2. public MongoEndpointProfile findByKeyHash(byte[] endpointKeyHash) {
  3. LOG.debug("Find endpoint profile by endpoint key hash [{}] ", endpointKeyHash);
  4. DBObject dbObject = query(where(EP_ENDPOINT_KEY_HASH)
  5. .is(endpointKeyHash))
  6. .getQueryObject();
  7. DBObject result = mongoTemplate.getDb()
  8. .getCollection(getCollectionName())
  9. .findOne(dbObject);
  10. return mongoTemplate.getConverter().read(getDocumentClass(), result);
  11. }

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

  1. @Override
  2. public MongoTopicListEntry findByHash(byte[] hash) {
  3. LOG.debug("Find topic list entry by hash [{}] ", hash);
  4. DBObject dbObject = query(where(ID).is(hash)).getQueryObject();
  5. DBObject result = mongoTemplate.getDb()
  6. .getCollection(getCollectionName())
  7. .findOne(dbObject);
  8. return mongoTemplate.getConverter().read(getDocumentClass(), result);
  9. }

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

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

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

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

相关文章