Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ pipeline {
stages {
stage("Docker images") {
parallel {
stage('Publish JDK (Java 24) + MongoDB 8.0') {
stage('Publish JDK (Java 25) + MongoDB 8.0') {
when {
anyOf {
changeset "ci/openjdk24-mongodb-8.0/**"
changeset "ci/openjdk25-mongodb-8.0/**"
changeset "ci/pipeline.properties"
}
}
Expand All @@ -32,7 +32,7 @@ pipeline {

steps {
script {
def image = docker.build("springci/spring-data-with-mongodb-8.0:${p['java.main.tag']}", "--build-arg BASE=${p['docker.java.main.image']} --build-arg MONGODB=${p['docker.mongodb.7.0.version']} ci/openjdk24-mongodb-8.0/")
def image = docker.build("springci/spring-data-with-mongodb-8.0:${p['java.main.tag']}", "--build-arg BASE=${p['docker.java.main.image']} --build-arg MONGODB=${p['docker.mongodb.7.0.version']} ci/openjdk25-mongodb-8.0/")
docker.withRegistry(p['docker.registry'], p['docker.credentials']) {
image.push()
}
Expand All @@ -42,7 +42,7 @@ pipeline {
stage('Publish JDK (Java.next) + MongoDB 8.0') {
when {
anyOf {
changeset "ci/openjdk24-mongodb-8.0/**"
changeset "ci/openjdk25-mongodb-8.0/**"
changeset "ci/pipeline.properties"
}
}
Expand All @@ -51,7 +51,7 @@ pipeline {

steps {
script {
def image = docker.build("springci/spring-data-with-mongodb-8.0:${p['java.next.tag']}", "--build-arg BASE=${p['docker.java.next.image']} --build-arg MONGODB=${p['docker.mongodb.8.0.version']} ci/openjdk24-mongodb-8.0/")
def image = docker.build("springci/spring-data-with-mongodb-8.0:${p['java.next.tag']}", "--build-arg BASE=${p['docker.java.next.image']} --build-arg MONGODB=${p['docker.mongodb.8.0.version']} ci/openjdk25-mongodb-8.0/")
docker.withRegistry(p['docker.registry'], p['docker.credentials']) {
image.push()
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>5.0.0-SNAPSHOT</version>
<version>5.0.0-GH-4852-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Spring Data MongoDB</name>
Expand Down
2 changes: 1 addition & 1 deletion spring-data-mongodb-distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>5.0.0-SNAPSHOT</version>
<version>5.0.0-GH-4852-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion spring-data-mongodb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>5.0.0-SNAPSHOT</version>
<version>5.0.0-GH-4852-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,16 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.springframework.data.annotation.QueryAnnotation;

/**
* Annotation to declare meta-information (execution time, cursor size, disk usage) for query methods.
*
* @author Christoph Strobl
* @author Mark Paluch
* @since 1.6
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
@Documented
@QueryAnnotation
public @interface Meta {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import org.springframework.data.geo.Point;

/**
* Annotation to be used for disambiguing method parameters that shall be used to trigger geo near queries. By default
* those parameters are found without the need for additional annotation if they are the only parameters of the
* Annotation to be used for disambiguating method parameters that shall be used to trigger geo near queries. By
* default, those parameters are found without the need for additional annotation if they are the only parameters of the
* according type (e.g. {@link Point}, {@code double[]}, {@link Distance}).
*
* @author Oliver Gierke
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public interface PersonRepository extends MongoRepository<Person, String>, Query
* @param lastname
* @return
*/
@Meta
List<Person> findByLastname(String lastname);

List<Person> findByLastnameStartsWith(String prefix);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.springframework.data.mongodb.core.convert.NoOpDbRefResolver;
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
import org.springframework.data.mongodb.core.query.TextCriteria;
import org.springframework.data.mongodb.repository.Meta;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Person;
import org.springframework.data.mongodb.repository.Person.Sex;
Expand Down Expand Up @@ -127,6 +128,12 @@ void doesNotDeriveFieldSpecForNormalDomainType() {
assertThat(deriveQueryFromMethod("findPersonBy", new Object[0]).getFieldsObject()).isEmpty();
}

@Test // GH-4852
void appliesMetaToPartTreeQuery() {
assertThat(deriveQueryFromMethod("findPersonBy", new Object[0]).getMeta()
.getMaxTimeMsec()).isEqualTo(1234L);
}

@Test // DATAMONGO-1345
void restrictsQueryToFieldsRequiredForProjection() {

Expand Down Expand Up @@ -193,7 +200,10 @@ private org.springframework.data.mongodb.core.query.Query deriveQueryFromMethod(
PartTreeMongoQuery partTreeQuery = createQueryForMethod(method, types);

MongoParameterAccessor accessor = new MongoParametersParameterAccessor(partTreeQuery.getQueryMethod(), args);
return partTreeQuery.createQuery(new ConvertingParameterAccessor(mongoOperationsMock.getConverter(), accessor));

org.springframework.data.mongodb.core.query.Query query = partTreeQuery.createQuery(new ConvertingParameterAccessor(mongoOperationsMock.getConverter(), accessor));
partTreeQuery.applyQueryMetaAttributesWhenPresent(query);
return query;
}

private PartTreeMongoQuery createQueryForMethod(String methodName, Class<?>... paramTypes) {
Expand Down Expand Up @@ -230,6 +240,7 @@ interface Repo extends MongoRepository<Person, Long> {
@Query(fields = "{ 'firstname }")
Person findByAge(Integer age);

@Meta(maxExecutionTimeMs = 1234)
Person findPersonBy();

PersonProjection findPersonProjectedBy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ lower / upper bounds (`$gt` / `$gte` & `$lt` / `$lte`) according to `Range`

NOTE: If the property criterion compares a document, the order of the fields and exact equality in the document matters.

NOTE: In some scenarios, you might require additional options, such as a maximum run time, additional log comments, or the permission to temporarily write data to disk.
Use the `@Meta` annotation to set those options via `maxExecutionTimeMs`, `comment` or `allowDiskUse`. `@Meta` can only be used on repository query methods, not on base interface or fragment interface methods.

[[mongodb.repositories.queries.geo-spatial]]
== Geo-spatial Queries

Expand Down Expand Up @@ -443,7 +446,7 @@ public interface PersonRepository extends ReactiveMongoRepository<Person, String
======

Expressions can be used to invoke functions, evaluate conditionals, and construct values.
SpEL expressions used in conjunction with JSON reveal a side-effect, because Map-like declarations inside of SpEL read like JSON, as the following example shows:
SpEL expressions used in conjunction with JSON reveal a side effect, because Map-like declarations inside of SpEL read like JSON, as the following example shows:

[tabs]
======
Expand Down