@Query("{ $and: [ {'scheduledNotifications.BACKUP.active': true }, { $where: 'this.scheduledNotifications.BACKUP.lastNotified < " + "new Date(new Date().setDate(new Date().getDate() - this.scheduledNotifications.BACKUP.frequency ))' }] }") List<Recipient> findReadyForBackup();
/** * Use a tailable cursor to emit a stream of entities as new entities are written to the capped collection. * * @return */ @Tailable Flowable<Person> findWithTailableCursorBy(); }
/** * Derived query using {@code $comment} meta attribute for quick lookup. <br /> * Have a look at the {@literal mongodb shell} and execute: * * <pre> * <code> * db['system.profile'].find({'query.$comment':'s2gx-2014-rocks!'}) * </code> * </pre> * * @param firstname * @return */ @Meta(comment = META_COMMENT) List<Customer> findByFirstname(String firstname); }
this.query = BINDING_PARSER.parseAndCollectParameterBindingsFromQueryIntoBindings(query, this.queryParameterBindings); this.fieldSpec = BINDING_PARSER.parseAndCollectParameterBindingsFromQueryIntoBindings( method.getFieldSpecification(), this.fieldSpecParameterBindings); this.parameterBinder = new ExpressionEvaluatingParameterBinder(expressionParser, evaluationContextProvider); if (method.hasAnnotatedQuery()) { org.springframework.data.mongodb.repository.Query queryAnnotation = method.getQueryAnnotation(); this.isCountQuery = queryAnnotation.count(); this.isExistsQuery = queryAnnotation.exists(); this.isDeleteQuery = queryAnnotation.delete(); if (hasAmbiguousProjectionFlags(this.isCountQuery, this.isExistsQuery, this.isDeleteQuery)) { throw new IllegalArgumentException(String.format(COUNT_EXISTS_AND_DELETE, method));
this.query = BINDING_PARSER.parseAndCollectParameterBindingsFromQueryIntoBindings(query, this.queryParameterBindings); this.fieldSpec = BINDING_PARSER.parseAndCollectParameterBindingsFromQueryIntoBindings( method.getFieldSpecification(), this.fieldSpecParameterBindings); if (method.hasAnnotatedQuery()) { org.springframework.data.mongodb.repository.Query queryAnnotation = method.getQueryAnnotation(); this.isCountQuery = queryAnnotation.count(); this.isExistsQuery = queryAnnotation.exists(); this.isDeleteQuery = queryAnnotation.delete(); if (hasAmbiguousProjectionFlags(this.isCountQuery, this.isExistsQuery, this.isDeleteQuery)) { throw new IllegalArgumentException(String.format(COUNT_EXISTS_AND_DELETE, method)); this.parameterBinder = new ExpressionEvaluatingParameterBinder(expressionParser, evaluationContextProvider);
Meta meta = getMetaAnnotation(); if (meta == null) { return new org.springframework.data.mongodb.core.query.Meta(); if (meta.maxExecutionTimeMs() > 0) { metaAttributes.setMaxTimeMsec(meta.maxExecutionTimeMs()); if (meta.maxScanDocuments() > 0) { metaAttributes.setMaxScan(meta.maxScanDocuments()); if (meta.cursorBatchSize() != 0) { metaAttributes.setCursorBatchSize(meta.cursorBatchSize()); if (StringUtils.hasText(meta.comment())) { metaAttributes.setComment(meta.comment()); if (meta.snapshot()) { metaAttributes.setSnapshot(meta.snapshot()); if (!ObjectUtils.isEmpty(meta.flags())) { for (org.springframework.data.mongodb.core.query.Meta.CursorOption option : meta.flags()) { metaAttributes.addFlag(option);
/** * Check if the query method is decorated with an non empty {@link Query#sort()}. * * @return true if method annotated with {@link Query} having an non empty sort attribute. * @since 2.1 */ public boolean hasAnnotatedSort() { return lookupQueryAnnotation().map(it -> !it.sort().isEmpty()).orElse(false); }
@Query("{ $and: [ {'scheduledNotifications.REMIND.active': true }, { $where: 'this.scheduledNotifications.REMIND.lastNotified < " + "new Date(new Date().setDate(new Date().getDate() - this.scheduledNotifications.REMIND.frequency ))' }] }") List<Recipient> findReadyForRemind();
this.query = BINDING_PARSER.parseAndCollectParameterBindingsFromQueryIntoBindings(query, this.queryParameterBindings); this.fieldSpec = BINDING_PARSER.parseAndCollectParameterBindingsFromQueryIntoBindings( method.getFieldSpecification(), this.fieldSpecParameterBindings); this.parameterBinder = new ExpressionEvaluatingParameterBinder(expressionParser, evaluationContextProvider); if (method.hasAnnotatedQuery()) { org.springframework.data.mongodb.repository.Query queryAnnotation = method.getQueryAnnotation(); this.isCountQuery = queryAnnotation.count(); this.isExistsQuery = queryAnnotation.exists(); this.isDeleteQuery = queryAnnotation.delete(); if (hasAmbiguousProjectionFlags(this.isCountQuery, this.isExistsQuery, this.isDeleteQuery)) { throw new IllegalArgumentException(String.format(COUNT_EXISTS_AND_DELETE, method));
this.query = BINDING_PARSER.parseAndCollectParameterBindingsFromQueryIntoBindings(query, this.queryParameterBindings); this.fieldSpec = BINDING_PARSER.parseAndCollectParameterBindingsFromQueryIntoBindings( method.getFieldSpecification(), this.fieldSpecParameterBindings); if (method.hasAnnotatedQuery()) { org.springframework.data.mongodb.repository.Query queryAnnotation = method.getQueryAnnotation(); this.isCountQuery = queryAnnotation.count(); this.isExistsQuery = queryAnnotation.exists(); this.isDeleteQuery = queryAnnotation.delete(); if (hasAmbiguousProjectionFlags(this.isCountQuery, this.isExistsQuery, this.isDeleteQuery)) { throw new IllegalArgumentException(String.format(COUNT_EXISTS_AND_DELETE, method)); this.parameterBinder = new ExpressionEvaluatingParameterBinder(expressionParser, evaluationContextProvider);
Meta meta = getMetaAnnotation(); if (meta == null) { return new org.springframework.data.mongodb.core.query.Meta(); if (meta.maxExecutionTimeMs() > 0) { metaAttributes.setMaxTimeMsec(meta.maxExecutionTimeMs()); if (meta.maxScanDocuments() > 0) { metaAttributes.setMaxScan(meta.maxScanDocuments()); if (meta.cursorBatchSize() != 0) { metaAttributes.setCursorBatchSize(meta.cursorBatchSize()); if (StringUtils.hasText(meta.comment())) { metaAttributes.setComment(meta.comment()); if (meta.snapshot()) { metaAttributes.setSnapshot(meta.snapshot()); if (!ObjectUtils.isEmpty(meta.flags())) { for (org.springframework.data.mongodb.core.query.Meta.CursorOption option : meta.flags()) { metaAttributes.addFlag(option);
/** * Use a tailable cursor to emit a stream of entities as new entities are written to the capped collection. * * @return */ @Tailable Flux<Person> findWithTailableCursorBy(); }
/** * Check if the query method is decorated with an non empty {@link Query#sort()}. * * @return true if method annotated with {@link Query} having an non empty sort attribute. * @since 2.1 */ public boolean hasAnnotatedSort() { return lookupQueryAnnotation().map(it -> !it.sort().isEmpty()).orElse(false); }
/** * String query selecting one entity. * * @param lastname * @return */ @Query("{ 'firstname': ?0, 'lastname': ?1}") Maybe<Person> findByFirstnameAndLastname(String firstname, String lastname);
/** * String query selecting one entity. * * @param lastname * @return */ @Query("{ 'firstname': ?0, 'lastname': ?1}") Mono<Person> findByFirstnameAndLastname(String firstname, String lastname);
@Query("{id: ?#{ hasRole('ROLE_ADMIN') ? {$exists:true} : principal.id}}") List<Person> findAllForCurrentUserById(); }
@Query("{}") Stream<Person> findAllByCustomQueryWithStream(); }
/** * Returns all {@link Product}s having the given attribute. * * @param attribute * @return */ @Query("{ ?0 : ?1 }") List<Product> findByAttributes(String key, String value); }
/** * Finds the {@link EnvironmentComponent} collector item id, environment name and component name. * * @param collectorItemId collector item id * @param environmentName environment name * @param componentName component name * @return a {@link EnvironmentComponent} */ @Query(value="{ collectorItemId : ?0, environmentName : ?1, componentName : ?2}") EnvironmentComponent findComponent(ObjectId collectorItemId, String environmentName, String componentName);
/** * Finds the {@link CollectorItem} for a given collector and options. This should represent a unique * instance of a {@link CollectorItem} for a given {@link com.capitalone.dashboard.model.Collector}. * * @param collectorId {@link com.capitalone.dashboard.model.Collector} id * @param options options * @return a {@link CollectorItem} */ @Query(value="{ 'collectorId' : ?0, options : ?1}") T findByCollectorAndOptions(ObjectId collectorId, Map<String, Object> options);