本文整理了Java中org.springframework.data.mongodb.core.query.Criteria.ne()
方法的一些代码示例,展示了Criteria.ne()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Criteria.ne()
方法的具体详情如下:
包路径:org.springframework.data.mongodb.core.query.Criteria
类名称:Criteria
方法名:ne
[英]Creates a criterion using the $ne operator.
[中]使用$ne运算符创建条件。
代码示例来源:origin: spring-projects/spring-data-mongodb
return criteria.gt(parameters.next()).lt(parameters.next());
case IS_NOT_NULL:
return criteria.ne(null);
case IS_NULL:
return criteria.is(null);
return isSimpleComparisionPossible(part) ? criteria.ne(parameters.next())
: createLikeRegexCriteriaOrThrow(part, property, criteria, parameters, true);
default:
代码示例来源:origin: pl.edu.icm.polindex/polindex-core
protected Criteria differentCitationIdCriterion(String citationId) {
return Criteria.where(F_ID).ne(citationId);
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public void addCondition(Criteria criteria, FilterCondition filter, CriteriaHolder criteriaHolder) {
criteria.ne(this.castValue(criteriaHolder, filter.getValue(), INCORRECT_FILTER_PARAMETERS));
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
return criteria.gt(parameters.next()).lt(parameters.next());
case IS_NOT_NULL:
return criteria.ne(null);
case IS_NULL:
return criteria.is(null);
return isSimpleComparisionPossible(part) ? criteria.ne(parameters.next())
: createLikeRegexCriteriaOrThrow(part, property, criteria, parameters, true);
default:
代码示例来源:origin: org.jspresso.framework/jspresso-mongo
crit = where(prefixedProperty).ne(null);
} else {
crit = where(prefixedProperty).is(null);
|| propertyDescriptor instanceof IEnumerationPropertyDescriptor) {
if (negate) {
crit = where(prefixedProperty).ne(val);
} else {
crit = where(prefixedProperty).is(val);
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public List<String> findIdsNotInIssueType(String issueType, String launchId) {
Query query = query(where(LAUNCH_REFERENCE).is(launchId)).addCriteria(where(ISSUE).exists(true))
.addCriteria(where(ISSUE_TYPE).ne(issueType));
query.fields().include(ID);
return mongoTemplate.find(query, TestItem.class).stream().map(TestItem::getId).collect(toList());
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public Optional<Launch> findLastLaunch(String projectId, String mode) {
Query query = query(where(PROJECT_ID_REFERENCE).is(projectId)).addCriteria(where(STATUS).ne(IN_PROGRESS))
.addCriteria(where(MODE).is(mode))
.limit(1)
.with(new Sort(DESC, START_TIME));
List<Launch> launches = mongoTemplate.find(query, Launch.class);
return !launches.isEmpty() ? Optional.of(launches.get(0)) : Optional.empty();
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public Optional<Launch> findLatestLaunch(String projectName, String launchName, String mode) {
Query query = query(where(PROJECT_ID_REFERENCE).is(projectName)).addCriteria(where(NAME).is(launchName))
.addCriteria(where(STATUS).ne(Status.IN_PROGRESS))
.addCriteria(where(MODE).is(mode))
.limit(1)
.with(new Sort(DESC, NUMBER));
List<Launch> launches = mongoTemplate.find(query, Launch.class);
return !launches.isEmpty() ? Optional.of(launches.get(0)) : Optional.empty();
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Cacheable(value = { CacheConfiguration.PROJECT_INFO_CACHE })
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Map<String, Integer> findGroupedLaunchesByOwner(String projectName, String mode, Date from) {
Map<String, Integer> output = new HashMap<>();
Aggregation aggregation = newAggregation(match(where(PROJECT_ID_REFERENCE).is(projectName)),
match(where(MODE).is(mode)),
match(where(STATUS).ne(IN_PROGRESS.name())),
match(where(START_TIME).gt(from)),
group("$userRef").count().as("count")
);
AggregationResults<Map> result = mongoTemplate.aggregate(aggregation, Launch.class, Map.class);
for (Map<String, String> entry : result.getMappedResults()) {
String username = entry.get("_id");
String count = String.valueOf(entry.get("count"));
output.put(username, Integer.valueOf(count));
}
return output;
}
代码示例来源:origin: sentilo/sentilo
public List<Tenant> findPublicsButNotMe(final String id) {
final Query query = new Query(Criteria.where("id").ne(id).and("isPublic").is(Boolean.TRUE));
return getMongoOps().find(query, Tenant.class);
}
代码示例来源:origin: onsoul/HA-DB
private long generate(MongoTemplate template, String collectionName, String rowName, Long incrementVal) {
Criteria criteria = Criteria.where(SequenceId.COLLNAME).is(collectionName);
if (rowName != null) {
criteria.and(SequenceId.ROW).is(rowName);
} else {
criteria.and(SequenceId.ROW).ne("").ne(null);
}
Query query = new Query(criteria);
Update update = new Update();
update.inc(SequenceId.SEQ, incrementVal);
FindAndModifyOptions options = new FindAndModifyOptions();
options.upsert(false); // 不做插入,所有的自增键由表维护
options.returnNew(true);
SequenceId seqId = template.findAndModify(query, update, options, SequenceId.class,
SequenceId.SEQUENCE_ID_COL_NAME);
return seqId.getSeq();
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public List<TestItem> findItemsNotInIssueType(String issueType, String launchId) {
Query query = query(where(LAUNCH_REFERENCE).is(launchId)).addCriteria(where(ISSUE).exists(true))
.addCriteria(where(ISSUE_TYPE).ne(issueType));
return mongoTemplate.find(query, TestItem.class);
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public void deleteUnsharedFilters(String username, String project, String filterId) {
Query query = Query.query(where("userRef").ne(username))
.addCriteria(where("projectRef").is(project))
.addCriteria(where("launchTabs.filters").is(filterId));
Update update = new Update().pull("launchTabs.filters", filterId);
mongoTemplate.updateMulti(query, update, UserPreference.class);
}
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public List<TestItem> findItemsByAutoAnalyzedStatus(boolean status, String launchId) {
return mongoTemplate.find(query(where(LAUNCH_REFERENCE).is(launchId)
.and(ISSUE)
.exists(true)
.and(ISSUE_TYPE)
.ne(TO_INVESTIGATE.getLocator())
.and(IGNORE_ANALYZER)
.is(false)
.and(ISSUE_ANALYZED)
.is(status)), TestItem.class);
}
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public Long findLaunchesQuantity(String projectId, String mode, Date from) {
Query query = query(where(PROJECT_ID_REFERENCE).is(projectId)).addCriteria(where(STATUS).ne(IN_PROGRESS.name()))
.addCriteria(where(MODE).is(mode));
if (null != from) {
query = query.addCriteria(where(START_TIME).gt(from));
}
return mongoTemplate.count(query, Launch.class);
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public List<Launch> findLaunchesByProjectId(String projectId, Date from, String mode) {
Query query = query(where(PROJECT_ID_REFERENCE).is(projectId)).addCriteria(where(STATUS).ne(IN_PROGRESS.name()))
.addCriteria(where(MODE).is(mode))
.addCriteria(where(START_TIME).gt(from))
.with(new Sort(Sort.Direction.ASC, START_TIME));
return mongoTemplate.find(query, Launch.class);
}
代码示例来源:origin: pl.edu.icm.synat/synat-business-services-impl
@Override
@RequiresServiceRole(roleName="READ")
public List<CollectionWithDocumentData> listBrowsableCollectionsWithElement(String elementId, String userId) {
Criteria criteriaForPublic = Criteria.where(F_ATTACHED_DOCUMENT_ID).is(elementId).andOperator(
Criteria.where(F_COLLECTION_VISIBILITY).is(CollectionVisibility.PUBLIC.name()),
Criteria.where(F_USERS_ID).ne(userId));
Criteria criteriaForUser = Criteria.where(F_ATTACHED_DOCUMENT_ID).is(elementId).andOperator(
Criteria.where(F_USERS_ID).is(userId),
Criteria.where(F_COLLECTION_TYPE).is(CollectionTypes.USERCOLLECTION.getTypeName()));
Query query = new Query(criteriaForPublic);
List<ElementCollection> items = mongoTemplate.find(query, ElementCollection.class, mongoCollectionName);
query = new Query(criteriaForUser);
items.addAll(mongoTemplate.find(query, ElementCollection.class, mongoCollectionName));
return convertWithDocument(items, elementId);
}
代码示例来源:origin: com.github.rutledgepaulv/q-builders
@Override
protected Criteria visit(ComparisonNode node) {
ComparisonOperator operator = node.getOperator();
Collection<?> values = node.getValues().stream().map(normalizer).collect(Collectors.toList());
String field = node.getField().asKey();
if(ComparisonOperator.EQ.equals(operator)) {
return where(field).is(single(values));
} else if(ComparisonOperator.NE.equals(operator)) {
return where(field).ne(single(values));
} else if (ComparisonOperator.EX.equals(operator)) {
return where(field).exists((Boolean)single(values));
} else if (ComparisonOperator.GT.equals(operator)) {
return where(field).gt(single(values));
} else if (ComparisonOperator.LT.equals(operator)) {
return where(field).lt(single(values));
} else if (ComparisonOperator.GTE.equals(operator)) {
return where(field).gte(single(values));
} else if (ComparisonOperator.LTE.equals(operator)) {
return where(field).lte(single(values));
} else if (ComparisonOperator.IN.equals(operator)) {
return where(field).in(values);
} else if (ComparisonOperator.NIN.equals(operator)) {
return where(field).nin(values);
} else if (ComparisonOperator.RE.equals(operator)) {
return where(field).regex((String)single(values));
} else if (ComparisonOperator.SUB_CONDITION_ANY.equals(operator)) {
return where(field).elemMatch(condition(node));
}
throw new UnsupportedOperationException("This visitor does not support the operator " + operator + ".");
}
代码示例来源:origin: org.jspresso.framework/jspresso-mongo
break;
case ComparableQueryStructureDescriptor.NN:
queryStructureRestriction.ne(null);
break;
case ComparableQueryStructureDescriptor.BE:
代码示例来源:origin: com.bq.oss.lib/queries-mongo
private Criteria criteria(QueryOperator operator, String field, QueryLiteral<?> value) {
Criteria criteria = new Criteria(field);
switch (operator) {
case $ALL:
return criteria.all(((ListQueryLiteral) value).getLiterals());
case $EQ:
return criteria.is(value.getLiteral());
case $GT:
return criteria.gt(value.getLiteral());
case $GTE:
return criteria.gte(value.getLiteral());
case $IN:
return criteria.in(((ListQueryLiteral) value).getLiterals());
case $NIN:
return criteria.nin(((ListQueryLiteral) value).getLiterals());
case $LT:
return criteria.lt(value.getLiteral());
case $LTE:
return criteria.lte(value.getLiteral());
case $NE:
return criteria.ne(value.getLiteral());
case $LIKE:
return criteria.regex((String) value.getLiteral(), "i"); // i means case insensitive
case $ELEM_MATCH:
return criteria.elemMatch(getCriteriaFromResourceQuery((ResourceQuery) value.getLiteral()));
case $EXISTS:
return criteria.exists((Boolean) value.getLiteral());
}
return criteria;
}
内容来源于网络,如有侵权,请联系作者删除!