本文整理了Java中org.springframework.data.mongodb.core.query.Criteria.and()
方法的一些代码示例,展示了Criteria.and()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Criteria.and()
方法的具体详情如下:
包路径:org.springframework.data.mongodb.core.query.Criteria
类名称:Criteria
方法名:and
[英]Static factory method to create a Criteria using the provided key
[中]使用提供的键创建条件的静态工厂方法
代码示例来源:origin: kaaproject/kaa
@Override
public void removeByUserIdAndAppTokenAndSchemaVersion(String userId,
String appToken,
Integer schemaVersion) {
remove(query(where(USER_CONF_USER_ID)
.is(userId)
.and(USER_CONF_APP_TOKEN)
.is(appToken)
.and(USER_CONF_SCHEMA_VERSION)
.is(schemaVersion)));
LOG.debug("Removed user specific configuration by user id {}, application token {} "
+ "and schema version {}", userId, appToken, schemaVersion);
}
}
代码示例来源:origin: kaaproject/kaa
@Override
public EndpointSpecificConfiguration findByEndpointKeyHashAndConfigurationVersion(byte[] endpointKeyHash, int configurationVersion) {
LOG.debug("Try to find endpoint specific configuration by endpointKeyHash {} and configurationVersion {}", endpointKeyHash, configurationVersion);
EndpointSpecificConfiguration configuration = findOne(query(where(EP_SPECIFIC_CONFIGURATION_KEY_HASH).is(endpointKeyHash)
.and(EP_CONFIGURATION_VERSION).is(configurationVersion)));
LOG.trace("Found {} endpoint specific configuration", configuration);
return configuration;
}
代码示例来源:origin: kaaproject/kaa
@Override
public MongoEndpointUserConfiguration
findByUserIdAndAppTokenAndSchemaVersion(
String userId,
String appToken,
Integer schemaVersion
) {
LOG.debug("Searching for user specific configuration by user id {}, "
+ "application token {} and schema version {}",
userId, appToken, schemaVersion);
MongoEndpointUserConfiguration userConfiguration = findOne(query(where(USER_CONF_USER_ID)
.is(userId).and(USER_CONF_APP_TOKEN)
.is(appToken)
.and(USER_CONF_SCHEMA_VERSION)
.is(schemaVersion)));
if (LOG.isTraceEnabled()) {
LOG.debug("[{},{},{}] Search result: {}.",
userId, appToken, schemaVersion, userConfiguration);
} else {
LOG.debug("[{},{},{}] Search result: {}.",
userId, appToken, schemaVersion, userConfiguration != null);
}
return userConfiguration;
}
代码示例来源:origin: kaaproject/kaa
@Override
public Optional<MongoCredentials> find(String applicationId, String credentialsId) {
LOG.debug("Searching for credentials by application ID [{}] and credentials ID [{}]",
applicationId, credentialsId);
Query query = Query.query(Criteria.where(MongoModelConstants.CREDENTIALS_ID)
.is(credentialsId)
.and(MongoModelConstants.APPLICATION_ID)
.is(applicationId));
return Optional.ofNullable(this.findOne(query));
}
代码示例来源:origin: kaaproject/kaa
@Override
public void removeByExternalIdAndTenantId(String externalId, String tenantId) {
LOG.debug("Remove user by external uid [{}] and tenant id [{}] ", externalId, tenantId);
remove(query(where(EP_USER_EXTERNAL_ID)
.is(externalId)
.and(EP_USER_TENANT_ID)
.is(tenantId)));
}
代码示例来源:origin: kaaproject/kaa
@Override
public void remove(String applicationId, String credentialsId) {
LOG.debug("Removing credentials [{}] from application [{}]", credentialsId, applicationId);
Query query = Query.query(Criteria.where(MongoModelConstants.CREDENTIALS_ID)
.is(credentialsId)
.and(MongoModelConstants.APPLICATION_ID)
.is(applicationId));
this.remove(query);
}
}
代码示例来源:origin: kaaproject/kaa
@Override
public MongoEndpointUser findByExternalIdAndTenantId(String externalId, String tenantId) {
LOG.debug("Find user by external uid [{}] and tenant id [{}] ", externalId, tenantId);
return findOne(query(where(EP_USER_EXTERNAL_ID)
.is(externalId).and(EP_USER_TENANT_ID)
.is(tenantId)));
}
代码示例来源:origin: kaaproject/kaa
@Override
public void removeByEndpointKeyHashAndConfigurationVersion(byte[] endpointKeyHash, Integer confSchemaVersion) {
LOG.debug("Remove endpoint specific configuration by endpoint key hash [{}] ", endpointKeyHash);
mongoTemplate.remove(
query(where(EP_SPECIFIC_CONFIGURATION_KEY_HASH).is(endpointKeyHash)
.and(EP_CONFIGURATION_VERSION).is(confSchemaVersion)), getCollectionName());
}
代码示例来源:origin: kaaproject/kaa
@Override
public List<MongoNotification>
findNotificationsByTopicIdAndVersionAndStartSecNum(
String topicId,
int seqNumber,
int sysNfVersion,
int userNfVersion
) {
LOG.debug("Find notifications by topic id [{}], sequence number start [{}], "
+ "system schema version [{}], user schema version [{}]",
topicId, seqNumber, sysNfVersion, userNfVersion);
return find(query(where(NF_TOPIC_ID)
.is(topicId)
.and(NF_SEQ_NUM)
.gt(seqNumber)
.orOperator(where(NF_VERSION)
.is(sysNfVersion)
.and(NF_TYPE)
.is(SYSTEM),
where(NF_VERSION)
.is(userNfVersion)
.and(NF_TYPE)
.is(USER))));
}
代码示例来源:origin: kaaproject/kaa
@Override
public Optional<MongoCredentials> updateStatus(String applicationId,
String credentialsId,
CredentialsStatus status) {
LOG.debug("Settings status [{}] for credentials [{}] in application [{}]",
status, credentialsId, applicationId);
updateFirst(
Query.query(Criteria.where(MongoModelConstants.CREDENTIALS_ID)
.is(credentialsId)
.and(MongoModelConstants.APPLICATION_ID)
.is(applicationId)),
Update.update(MongoModelConstants.CREDENTIAL_STATUS, status));
return this.find(applicationId, credentialsId);
}
代码示例来源:origin: spring-projects/spring-data-mongodb
@Override
protected Criteria and(Part part, Criteria base, Iterator<Object> iterator) {
if (base == null) {
return create(part, iterator);
}
PersistentPropertyPath<MongoPersistentProperty> path = context.getPersistentPropertyPath(part.getProperty());
MongoPersistentProperty property = path.getLeafProperty();
return from(part, property, base.and(path.toDotPath()), iterator);
}
代码示例来源:origin: spring-projects/spring-data-mongodb
@Override
public Query getQueryForVersion() {
MongoPersistentProperty idProperty = entity.getRequiredIdProperty();
MongoPersistentProperty property = entity.getRequiredVersionProperty();
return new Query(Criteria.where(idProperty.getName()).is(getId())//
.and(property.getName()).is(getVersion()));
}
代码示例来源:origin: spring-projects/spring-integration
@Override
@ManagedAttribute
public int getMessageCountForAllMessageGroups() {
Query query = Query.query(Criteria.where(MessageDocumentFields.MESSAGE_ID).exists(true)
.and(MessageDocumentFields.GROUP_ID).exists(true));
long count = this.template.count(query, this.collectionName);
Assert.isTrue(count <= Integer.MAX_VALUE, "Message count is out of Integer's range");
return (int) count;
}
代码示例来源:origin: spring-projects/spring-integration
private static Query whereMessageIdIsAndGroupIdIs(UUID id, Object groupId) {
return new Query(Criteria.where("headers.id").is(id).and(GROUP_ID_KEY).is(groupId));
}
代码示例来源:origin: spring-projects/spring-integration
/**
* Replace an existing metadata entry {@code value} with a new one. Otherwise does nothing.
* Performs {@code updateFirst} if a document for the provided {@code key} and {@code oldValue}
* exists in the {@link #collectionName}.
* @param key the metadata entry key
* @param oldValue the metadata entry old value to replace
* @param newValue the metadata entry new value to put
* @return {@code true} if replace was successful, {@code false} otherwise.
* @see MongoTemplate#updateFirst(Query, Update, String)
*/
@Override
public boolean replace(String key, String oldValue, String newValue) {
Assert.hasText(key, "'key' must not be empty.");
Assert.hasText(oldValue, "'oldValue' must not be empty.");
Assert.hasText(newValue, "'newValue' must not be empty.");
Query query = new Query(Criteria.where(ID_FIELD).is(key).and(VALUE).is(oldValue));
return this.template.updateFirst(query, Update.update(VALUE, newValue), this.collectionName)
.getModifiedCount() > 0;
}
代码示例来源:origin: spring-projects/spring-integration
@Override
@ManagedAttribute
public int getMessageCountForAllMessageGroups() {
Query query = Query.query(Criteria.where(MessageDocumentFields.MESSAGE_ID).exists(true)
.and(MessageDocumentFields.GROUP_ID).exists(true));
long count = this.mongoTemplate.count(query, this.collectionName);
Assert.isTrue(count <= Integer.MAX_VALUE, "Message count is out of Integer's range");
return (int) count;
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
@Override
protected Criteria and(Part part, Criteria base, Iterator<Object> iterator) {
if (base == null) {
return create(part, iterator);
}
PersistentPropertyPath<MongoPersistentProperty> path = context.getPersistentPropertyPath(part.getProperty());
MongoPersistentProperty property = path.getLeafProperty();
return from(part, property, base.and(path.toDotPath()), iterator);
}
代码示例来源:origin: spring-projects/spring-integration
@Override
public long getMessageCount() {
Query query = Query.query(Criteria.where(MessageDocumentFields.MESSAGE_ID).exists(true)
.and(MessageDocumentFields.GROUP_ID).exists(false));
return this.mongoTemplate.getCollection(this.collectionName).countDocuments(query.getQueryObject());
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
@Override
public Query getQueryForVersion() {
MongoPersistentProperty idProperty = entity.getRequiredIdProperty();
MongoPersistentProperty property = entity.getRequiredVersionProperty();
return new Query(Criteria.where(idProperty.getName()).is(getId())//
.and(property.getName()).is(getVersion()));
}
代码示例来源:origin: io.gravitee.repository/gravitee-repository-mongodb
@Override
public Iterator<RateLimit> findAsyncAfter(long timestamp) {
final Query query = Query.query(Criteria.where(FIELD_ASYNC).is(true).and(FIELD_UPDATED_AT).gte(timestamp));
return mongoOperations.find(query, Document.class, RATE_LIMIT_COLLECTION)
.stream()
.map(this::convert)
.iterator();
}
内容来源于网络,如有侵权,请联系作者删除!