Compare commits

...

23 Commits

Author SHA1 Message Date
Oliver Gierke
909a0bb2f2 DATAMONGO-1669 - Release version 1.10.3 (Ingalls SR3). 2017-04-19 19:32:38 +02:00
Oliver Gierke
c3983a4a32 DATAMONGO-1669 - Prepare 1.10.3 (Ingalls SR3). 2017-04-19 19:32:01 +02:00
Oliver Gierke
94cd8fd827 DATAMONGO-1669 - Updated changelog. 2017-04-19 19:31:54 +02:00
Oliver Gierke
34ca906b80 DATAMONGO-1634 - Updated changelog. 2017-04-19 13:04:10 +02:00
Oliver Gierke
0a9f7d0e30 DATAMONGO-1633 - After release cleanups. 2017-04-19 11:48:46 +02:00
Oliver Gierke
36af892679 DATAMONGO-1633 - Prepare next development iteration. 2017-04-19 11:48:42 +02:00
Oliver Gierke
12f3dce709 DATAMONGO-1633 - Release version 1.10.2 (Ingalls SR2). 2017-04-19 10:11:28 +02:00
Oliver Gierke
ae3b4be772 DATAMONGO-1633 - Prepare 1.10.2 (Ingalls SR2). 2017-04-19 10:10:47 +02:00
Oliver Gierke
4f813ae7a7 DATAMONGO-1633 - Updated changelog. 2017-04-19 10:10:39 +02:00
Mark Paluch
bd92f67e54 DATAMONGO-1666 - Consider collection type in bulk DBRef fetching.
We now consider the property's collection type after bulk-fetching DBRefs before returning the actual result value. The issue got only visible if bulk fetching is possible and constructor creation is used. Setting the property value on through an property accessor works fine because the property accessor checks all values for assignability and potentially converts values to their target type. That's different for constructor creation.

Original Pull Request: #457
2017-04-13 11:27:26 +02:00
Oliver Gierke
63968513d9 DATAMONGO-1535 - Updated changelog. 2017-04-10 13:44:19 +02:00
Michael J. Simons
2b0026931a DATAMONGO-1662 - Fix classname in reference docs about projections in aggregations.
Original pull request: #455.
2017-04-10 09:12:38 +02:00
Mark Paluch
0df5e6ba58 DATAMONGO-1645 - Polishing.
Clean up appender and log level after test run. Suppress log output during tests.

Original pull request: #450.
2017-03-21 10:52:35 +01:00
Christoph Strobl
2a0a880f57 DATAMONGO-1645 - Safely serialize JSON output for log message in LoggingEventListener.
We now make sure to safely serialize JSON output for mapped documents. This prevents the logger from rendering false exception messages to log appender.

Original pull request: #450.
2017-03-21 10:33:37 +01:00
Mark Paluch
d920cee5e7 DATAMONGO-1620 - Polishing.
Use Integer.MIN_VALUE as placeholder for unset values to allow setting zero (immediately) and -1 (indefinite wait) server selection timeouts. Fix test method name. Add JavaDoc.

Original pull request: #449.
2017-03-13 16:21:12 +01:00
Christoph Strobl
3af2d810bc DATAMONGO-1620 - Add server-selection-timeout to XML MongoClientOptions config.
We now allow server-selection-timeout attribute on MongoClientOptions XML configuration for a MongoDB 3.x client.

Original pull request: #449.
2017-03-13 16:21:12 +01:00
Mark Paluch
a4c754467e DATAMONGO-1421 - Polishing.
Remove trailing whitespaces. Construct exception message with String.format(…).

Original pull request: #448.
2017-03-08 08:47:58 +01:00
Christoph Strobl
0ab635d7ee DATAMONGO-1421 - Fix serialization in error message causing error itself.
We now make sure to safely serialize the criteria object used for creating the error message when raising an `InvalidMongoDbApiUsageException` in cases where `addCriteria` is used to add multiple entries for the same property.

Original pull request: #448.
2017-03-08 08:47:58 +01:00
Oliver Gierke
ef46edc941 DATAMONGO-1639 - Polishing.
Formatting in MongoTemplateUnitTests.
2017-03-06 16:24:44 +01:00
Oliver Gierke
93f81f7321 DATAMONGO-1639 - Make sure BeforeConvertEvent sees new version for updates.
The changes for DATAMONGO-1617 subtley changed the behavior for entity updates in terms of the version value they see for entities using optimistic locking. Previously the updates already saw the new version value, where after the fix for DATAMONGO-1617 it saw the old one. That caused BeforeConvertEvent listeners not being able to distinguish between an original insert and the first update anymore.

This change is now rolled back and we introduced a test case that encodes this expectation explicitly.
2017-03-06 16:24:44 +01:00
Oliver Gierke
f42c24a605 DATAMONGO-1597 - Updated changelog. 2017-03-02 16:57:50 +01:00
Oliver Gierke
1ac88e44a1 DATAMONGO-1598 - After release cleanups. 2017-03-02 10:21:53 +01:00
Oliver Gierke
324f656410 DATAMONGO-1598 - Prepare next development iteration. 2017-03-02 10:21:36 +01:00
22 changed files with 1332 additions and 82 deletions

View File

@@ -5,7 +5,7 @@
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>1.10.1.RELEASE</version>
<version>1.10.3.RELEASE</version>
<packaging>pom</packaging>
<name>Spring Data MongoDB</name>
@@ -15,7 +15,7 @@
<parent>
<groupId>org.springframework.data.build</groupId>
<artifactId>spring-data-parent</artifactId>
<version>1.9.1.RELEASE</version>
<version>1.9.3.RELEASE</version>
</parent>
<modules>
@@ -28,7 +28,7 @@
<properties>
<project.type>multi</project.type>
<dist.id>spring-data-mongodb</dist.id>
<springdata.commons>1.13.1.RELEASE</springdata.commons>
<springdata.commons>1.13.3.RELEASE</springdata.commons>
<mongo>2.14.3</mongo>
<mongo.osgi>2.13.0</mongo.osgi>
</properties>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>1.10.1.RELEASE</version>
<version>1.10.3.RELEASE</version>
<relativePath>../pom.xml</relativePath>
</parent>
@@ -48,7 +48,7 @@
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>1.10.1.RELEASE</version>
<version>1.10.3.RELEASE</version>
</dependency>
<dependency>

View File

@@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>1.10.1.RELEASE</version>
<version>1.10.3.RELEASE</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>1.10.1.RELEASE</version>
<version>1.10.3.RELEASE</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -11,7 +11,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>1.10.1.RELEASE</version>
<version>1.10.3.RELEASE</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2015 the original author or authors.
* Copyright 2011-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -129,6 +129,7 @@ abstract class MongoParsingUtils {
setPropertyValue(clientOptionsDefBuilder, optionsElement, "heartbeat-socket-timeout", "heartbeatSocketTimeout");
setPropertyValue(clientOptionsDefBuilder, optionsElement, "ssl", "ssl");
setPropertyReference(clientOptionsDefBuilder, optionsElement, "ssl-socket-factory-ref", "sslSocketFactory");
setPropertyValue(clientOptionsDefBuilder, optionsElement, "server-selection-timeout", "serverSelectionTimeout");
mongoClientBuilder.addPropertyValue("mongoClientOptions", clientOptionsDefBuilder.getBeanDefinition());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,8 +18,10 @@ package org.springframework.data.mongodb.core;
import javax.net.SocketFactory;
import javax.net.ssl.SSLSocketFactory;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.config.AbstractFactoryBean;
import org.springframework.data.mongodb.MongoDbFactory;
import org.springframework.data.mongodb.util.MongoClientVersion;
import com.mongodb.DBDecoderFactory;
import com.mongodb.DBEncoderFactory;
@@ -30,7 +32,7 @@ import com.mongodb.WriteConcern;
/**
* A factory bean for construction of a {@link MongoClientOptions} instance.
*
*
* @author Christoph Strobl
* @author Oliver Gierke
* @since 1.7
@@ -62,13 +64,14 @@ public class MongoClientOptionsFactoryBean extends AbstractFactoryBean<MongoClie
private int heartbeatConnectTimeout = DEFAULT_MONGO_OPTIONS.getHeartbeatConnectTimeout();
private int heartbeatSocketTimeout = DEFAULT_MONGO_OPTIONS.getHeartbeatSocketTimeout();
private String requiredReplicaSetName = DEFAULT_MONGO_OPTIONS.getRequiredReplicaSetName();
private int serverSelectionTimeout = Integer.MIN_VALUE;
private boolean ssl;
private SSLSocketFactory sslSocketFactory;
/**
* Set the {@link MongoClient} description.
*
*
* @param description
*/
public void setDescription(String description) {
@@ -77,7 +80,7 @@ public class MongoClientOptionsFactoryBean extends AbstractFactoryBean<MongoClie
/**
* Set the minimum number of connections per host.
*
*
* @param minConnectionsPerHost
*/
public void setMinConnectionsPerHost(int minConnectionsPerHost) {
@@ -87,7 +90,7 @@ public class MongoClientOptionsFactoryBean extends AbstractFactoryBean<MongoClie
/**
* Set the number of connections allowed per host. Will block if run out. Default is 10. System property
* {@code MONGO.POOLSIZE} can override
*
*
* @param connectionsPerHost
*/
public void setConnectionsPerHost(int connectionsPerHost) {
@@ -98,7 +101,7 @@ public class MongoClientOptionsFactoryBean extends AbstractFactoryBean<MongoClie
* Set the multiplier for connectionsPerHost for # of threads that can block. Default is 5. If connectionsPerHost is
* 10, and threadsAllowedToBlockForConnectionMultiplier is 5, then 50 threads can block more than that and an
* exception will be thrown.
*
*
* @param threadsAllowedToBlockForConnectionMultiplier
*/
public void setThreadsAllowedToBlockForConnectionMultiplier(int threadsAllowedToBlockForConnectionMultiplier) {
@@ -107,7 +110,7 @@ public class MongoClientOptionsFactoryBean extends AbstractFactoryBean<MongoClie
/**
* Set the max wait time of a blocking thread for a connection. Default is 12000 ms (2 minutes)
*
*
* @param maxWaitTime
*/
public void setMaxWaitTime(int maxWaitTime) {
@@ -116,7 +119,7 @@ public class MongoClientOptionsFactoryBean extends AbstractFactoryBean<MongoClie
/**
* The maximum idle time for a pooled connection.
*
*
* @param maxConnectionIdleTime
*/
public void setMaxConnectionIdleTime(int maxConnectionIdleTime) {
@@ -125,7 +128,7 @@ public class MongoClientOptionsFactoryBean extends AbstractFactoryBean<MongoClie
/**
* Set the maximum life time for a pooled connection.
*
*
* @param maxConnectionLifeTime
*/
public void setMaxConnectionLifeTime(int maxConnectionLifeTime) {
@@ -134,7 +137,7 @@ public class MongoClientOptionsFactoryBean extends AbstractFactoryBean<MongoClie
/**
* Set the connect timeout in milliseconds. 0 is default and infinite.
*
*
* @param connectTimeout
*/
public void setConnectTimeout(int connectTimeout) {
@@ -143,7 +146,7 @@ public class MongoClientOptionsFactoryBean extends AbstractFactoryBean<MongoClie
/**
* Set the socket timeout. 0 is default and infinite.
*
*
* @param socketTimeout
*/
public void setSocketTimeout(int socketTimeout) {
@@ -152,7 +155,7 @@ public class MongoClientOptionsFactoryBean extends AbstractFactoryBean<MongoClie
/**
* Set the keep alive flag, controls whether or not to have socket keep alive timeout. Defaults to false.
*
*
* @param socketKeepAlive
*/
public void setSocketKeepAlive(boolean socketKeepAlive) {
@@ -161,7 +164,7 @@ public class MongoClientOptionsFactoryBean extends AbstractFactoryBean<MongoClie
/**
* Set the {@link ReadPreference}.
*
*
* @param readPreference
*/
public void setReadPreference(ReadPreference readPreference) {
@@ -171,7 +174,7 @@ public class MongoClientOptionsFactoryBean extends AbstractFactoryBean<MongoClie
/**
* Set the {@link WriteConcern} that will be the default value used when asking the {@link MongoDbFactory} for a DB
* object.
*
*
* @param writeConcern
*/
public void setWriteConcern(WriteConcern writeConcern) {
@@ -187,7 +190,7 @@ public class MongoClientOptionsFactoryBean extends AbstractFactoryBean<MongoClie
/**
* Set the frequency that the driver will attempt to determine the current state of each server in the cluster.
*
*
* @param heartbeatFrequency
*/
public void setHeartbeatFrequency(int heartbeatFrequency) {
@@ -197,7 +200,7 @@ public class MongoClientOptionsFactoryBean extends AbstractFactoryBean<MongoClie
/**
* In the event that the driver has to frequently re-check a server's availability, it will wait at least this long
* since the previous check to avoid wasted effort.
*
*
* @param minHeartbeatFrequency
*/
public void setMinHeartbeatFrequency(int minHeartbeatFrequency) {
@@ -206,7 +209,7 @@ public class MongoClientOptionsFactoryBean extends AbstractFactoryBean<MongoClie
/**
* Set the connect timeout for connections used for the cluster heartbeat.
*
*
* @param heartbeatConnectTimeout
*/
public void setHeartbeatConnectTimeout(int heartbeatConnectTimeout) {
@@ -215,7 +218,7 @@ public class MongoClientOptionsFactoryBean extends AbstractFactoryBean<MongoClie
/**
* Set the socket timeout for connections used for the cluster heartbeat.
*
*
* @param heartbeatSocketTimeout
*/
public void setHeartbeatSocketTimeout(int heartbeatSocketTimeout) {
@@ -224,7 +227,7 @@ public class MongoClientOptionsFactoryBean extends AbstractFactoryBean<MongoClie
/**
* Configures the name of the replica set.
*
*
* @param requiredReplicaSetName
*/
public void setRequiredReplicaSetName(String requiredReplicaSetName) {
@@ -233,7 +236,7 @@ public class MongoClientOptionsFactoryBean extends AbstractFactoryBean<MongoClie
/**
* This controls if the driver should us an SSL connection. Defaults to |@literal false}.
*
*
* @param ssl
*/
public void setSsl(boolean ssl) {
@@ -243,24 +246,41 @@ public class MongoClientOptionsFactoryBean extends AbstractFactoryBean<MongoClie
/**
* Set the {@link SSLSocketFactory} to use for the {@literal SSL} connection. If none is configured here,
* {@link SSLSocketFactory#getDefault()} will be used.
*
*
* @param sslSocketFactory
*/
public void setSslSocketFactory(SSLSocketFactory sslSocketFactory) {
this.sslSocketFactory = sslSocketFactory;
}
/*
/**
* Set the {@literal server selection timeout} in msec for a 3.x MongoDB Java driver. If not set the default value of
* 30 sec will be used. A value of 0 means that it will timeout immediately if no server is available. A negative
* value means to wait indefinitely.
*
* @param serverSelectionTimeout in msec.
*/
public void setServerSelectionTimeout(int serverSelectionTimeout) {
this.serverSelectionTimeout = serverSelectionTimeout;
}
/*
* (non-Javadoc)
* @see org.springframework.beans.factory.config.AbstractFactoryBean#createInstance()
*/
@Override
protected MongoClientOptions createInstance() throws Exception {
SocketFactory socketFactoryToUse = ssl ? (sslSocketFactory != null ? sslSocketFactory : SSLSocketFactory
.getDefault()) : this.socketFactory;
SocketFactory socketFactoryToUse = ssl
? (sslSocketFactory != null ? sslSocketFactory : SSLSocketFactory.getDefault()) : this.socketFactory;
return MongoClientOptions.builder() //
MongoClientOptions.Builder builder = MongoClientOptions.builder();
if (MongoClientVersion.isMongo3Driver() && serverSelectionTimeout != Integer.MIN_VALUE) {
new DirectFieldAccessor(builder).setPropertyValue("serverSelectionTimeout", serverSelectionTimeout);
}
return builder //
.alwaysUseMBeans(this.alwaysUseMBeans) //
.connectionsPerHost(this.connectionsPerHost) //
.connectTimeout(connectTimeout) //

View File

@@ -1001,16 +1001,12 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware {
doInsert(collectionName, objectToSave, this.mongoConverter);
} else {
maybeEmitEvent(new BeforeConvertEvent<T>(objectToSave, collectionName));
assertUpdateableIdIfNotSet(objectToSave);
// Create query for entity with the id and old version
Object id = convertingAccessor.getProperty(idProperty);
Query query = new Query(Criteria.where(idProperty.getName()).is(id).and(versionProperty.getName()).is(version));
// Bump version number
convertingAccessor.setProperty(versionProperty, versionNumber.longValue() + 1);
maybeEmitEvent(new BeforeConvertEvent<T>(objectToSave, collectionName));
assertUpdateableIdIfNotSet(objectToSave);
BasicDBObject dbObject = new BasicDBObject();
this.mongoConverter.write(objectToSave, dbObject);
@@ -1018,6 +1014,10 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware {
maybeEmitEvent(new BeforeSaveEvent<T>(objectToSave, dbObject, collectionName));
Update update = Update.fromDBObject(dbObject, ID_FIELD);
// Create query for entity with the id and old version
Object id = convertingAccessor.getProperty(idProperty);
Query query = new Query(Criteria.where(idProperty.getName()).is(id).and(versionProperty.getName()).is(version));
doUpdate(collectionName, query, update, objectToSave.getClass(), false, false);
maybeEmitEvent(new AfterSaveEvent<T>(objectToSave, dbObject, collectionName));
}

View File

@@ -28,6 +28,7 @@ import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@@ -904,7 +905,10 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
}
if (!DBRef.class.equals(rawComponentType) && isCollectionOfDbRefWhereBulkFetchIsPossible(sourceValue)) {
return bulkReadAndConvertDBRefs((List<DBRef>) (List) (sourceValue), componentType, path, rawComponentType);
List<Object> objects = bulkReadAndConvertDBRefs((List<DBRef>)(List) sourceValue, componentType, path,
rawComponentType);
return getPotentiallyConvertedSimpleRead(objects, targetType.getType());
}
for (Object dbObjItem : sourceValue) {
@@ -1314,7 +1318,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
/**
* Returns whether the given {@link Iterable} contains {@link DBRef} instances all pointing to the same collection.
*
*
* @param source must not be {@literal null}.
* @return
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2016 the original author or authors.
* Copyright 2011-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
*/
package org.springframework.data.mongodb.core.mapping.event;
import static org.springframework.data.mongodb.core.query.SerializationUtils.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
@@ -25,6 +27,7 @@ import org.springframework.context.ApplicationListener;
* @author Jon Brisbin
* @author Martin Baumgartner
* @author Oliver Gierke
* @author Christoph Strobl
*/
public class LoggingEventListener extends AbstractMongoEventListener<Object> {
@@ -45,7 +48,7 @@ public class LoggingEventListener extends AbstractMongoEventListener<Object> {
*/
@Override
public void onBeforeSave(BeforeSaveEvent<Object> event) {
LOGGER.info("onBeforeSave: {}, {}", event.getSource(), event.getDBObject());
LOGGER.info("onBeforeSave: {}, {}", event.getSource(), serializeToJsonSafely(event.getDBObject()));
}
/*
@@ -54,7 +57,7 @@ public class LoggingEventListener extends AbstractMongoEventListener<Object> {
*/
@Override
public void onAfterSave(AfterSaveEvent<Object> event) {
LOGGER.info("onAfterSave: {}, {}", event.getSource(), event.getDBObject());
LOGGER.info("onAfterSave: {}, {}", event.getSource(), serializeToJsonSafely(event.getDBObject()));
}
/*
@@ -63,7 +66,7 @@ public class LoggingEventListener extends AbstractMongoEventListener<Object> {
*/
@Override
public void onAfterLoad(AfterLoadEvent<Object> event) {
LOGGER.info("onAfterLoad: {}", event.getDBObject());
LOGGER.info("onAfterLoad: {}", serializeToJsonSafely(event.getDBObject()));
}
/*
@@ -72,7 +75,7 @@ public class LoggingEventListener extends AbstractMongoEventListener<Object> {
*/
@Override
public void onAfterConvert(AfterConvertEvent<Object> event) {
LOGGER.info("onAfterConvert: {}, {}", event.getDBObject(), event.getSource());
LOGGER.info("onAfterConvert: {}, {}", serializeToJsonSafely(event.getDBObject()), event.getSource());
}
/*
@@ -81,7 +84,7 @@ public class LoggingEventListener extends AbstractMongoEventListener<Object> {
*/
@Override
public void onAfterDelete(AfterDeleteEvent<Object> event) {
LOGGER.info("onAfterDelete: {}", event.getDBObject());
LOGGER.info("onAfterDelete: {}", serializeToJsonSafely(event.getDBObject()));
}
/*
@@ -90,6 +93,6 @@ public class LoggingEventListener extends AbstractMongoEventListener<Object> {
*/
@Override
public void onBeforeDelete(BeforeDeleteEvent<Object> event) {
LOGGER.info("onBeforeDelete: {}", event.getDBObject());
LOGGER.info("onBeforeDelete: {}", serializeToJsonSafely(event.getDBObject()));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2016 the original author or authors.
* Copyright 2010-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -59,7 +59,7 @@ public class Query {
/**
* Static factory method to create a {@link Query} using the provided {@link CriteriaDefinition}.
*
*
* @param criteriaDefinition must not be {@literal null}.
* @return
* @since 1.6
@@ -72,7 +72,7 @@ public class Query {
/**
* Creates a new {@link Query} using the given {@link CriteriaDefinition}.
*
*
* @param criteriaDefinition must not be {@literal null}.
* @since 1.6
*/
@@ -82,7 +82,7 @@ public class Query {
/**
* Adds the given {@link CriteriaDefinition} to the current {@link Query}.
*
*
* @param criteriaDefinition must not be {@literal null}.
* @return
* @since 1.6
@@ -96,8 +96,8 @@ public class Query {
this.criteria.put(key, criteriaDefinition);
} else {
throw new InvalidMongoDbApiUsageException(
"Due to limitations of the com.mongodb.BasicDBObject, " + "you can't add a second '" + key + "' criteria. "
+ "Query already contains '" + existing.getCriteriaObject() + "'.");
String.format("Due to limitations of the com.mongodb.BasicDBObject, you can't add a second '%s' criteria. "
+ "Query already contains '%s'", key, serializeToJsonSafely(existing.getCriteriaObject())));
}
return this;
@@ -112,7 +112,7 @@ public class Query {
/**
* Set number of documents to skip before returning results.
*
*
* @param skip
* @return
*/
@@ -123,7 +123,7 @@ public class Query {
/**
* Limit the number of returned documents to {@code limit}.
*
*
* @param limit
* @return
*/
@@ -134,7 +134,7 @@ public class Query {
/**
* Configures the query to use the given hint when being executed.
*
*
* @param name must not be {@literal null} or empty.
* @return
*/
@@ -147,7 +147,7 @@ public class Query {
/**
* Sets the given pagination information on the {@link Query} instance. Will transparently set {@code skip} and
* {@code limit} as well as applying the {@link Sort} instance defined with the {@link Pageable}.
*
*
* @param pageable
* @return
*/
@@ -165,7 +165,7 @@ public class Query {
/**
* Adds a {@link Sort} to the {@link Query} instance.
*
*
* @param sort
* @return
*/
@@ -200,7 +200,7 @@ public class Query {
/**
* Restricts the query to only return documents instances that are exactly of the given types.
*
*
* @param type may not be {@literal null}
* @param additionalTypes may not be {@literal null}
* @return
@@ -254,7 +254,7 @@ public class Query {
/**
* Get the number of documents to skip.
*
*
* @return
*/
public int getSkip() {
@@ -263,7 +263,7 @@ public class Query {
/**
* Get the maximum number of documents to be return.
*
*
* @return
*/
public int getLimit() {
@@ -433,7 +433,7 @@ public class Query {
/**
* Tests whether the settings of the given {@link Query} are equal to this query.
*
*
* @param that
* @return
*/
@@ -450,7 +450,7 @@ public class Query {
return criteriaEqual && fieldsEqual && sortEqual && hintEqual && skipEqual && limitEqual && metaEqual;
}
/*
/*
* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@@ -472,7 +472,7 @@ public class Query {
/**
* Returns whether the given key is the one used to hold the type restriction information.
*
*
* @deprecated don't call this method as the restricted type handling will undergo some significant changes going
* forward.
* @param key

View File

@@ -7,4 +7,5 @@ http\://www.springframework.org/schema/data/mongo/spring-mongo-1.5.xsd=org/sprin
http\://www.springframework.org/schema/data/mongo/spring-mongo-1.7.xsd=org/springframework/data/mongodb/config/spring-mongo-1.7.xsd
http\://www.springframework.org/schema/data/mongo/spring-mongo-1.8.xsd=org/springframework/data/mongodb/config/spring-mongo-1.8.xsd
http\://www.springframework.org/schema/data/mongo/spring-mongo-1.10.xsd=org/springframework/data/mongodb/config/spring-mongo-1.10.xsd
http\://www.springframework.org/schema/data/mongo/spring-mongo.xsd=org/springframework/data/mongodb/config/spring-mongo-1.10.xsd
http\://www.springframework.org/schema/data/mongo/spring-mongo-1.10.2.xsd=org/springframework/data/mongodb/config/spring-mongo-1.10.2.xsd
http\://www.springframework.org/schema/data/mongo/spring-mongo.xsd=org/springframework/data/mongodb/config/spring-mongo-1.10.2.xsd

View File

@@ -0,0 +1,901 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns="http://www.springframework.org/schema/data/mongo"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:tool="http://www.springframework.org/schema/tool"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:repository="http://www.springframework.org/schema/data/repository"
targetNamespace="http://www.springframework.org/schema/data/mongo"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xsd:import namespace="http://www.springframework.org/schema/beans" />
<xsd:import namespace="http://www.springframework.org/schema/tool" />
<xsd:import namespace="http://www.springframework.org/schema/context" />
<xsd:import namespace="http://www.springframework.org/schema/data/repository"
schemaLocation="http://www.springframework.org/schema/data/repository/spring-repository.xsd" />
<xsd:element name="mongo" type="mongoType">
<xsd:annotation>
<xsd:documentation source="org.springframework.data.mongodb.core.MongoFactoryBean"><![CDATA[
Deprecated since 1.7 - use mongo-client instead. Defines a Mongo instance used for accessing MongoDB.
]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation>
<tool:exports type="com.mongodb.Mongo"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="mongo-client" type="mongoClientType">
<xsd:annotation>
<xsd:documentation source="org.springframework.data.mongodb.core.MongoClientFactoryBean"><![CDATA[
Defines a MongoClient instance used for accessing MongoDB.
]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation>
<tool:exports type="com.mongodb.MongoClient"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="db-factory">
<xsd:annotation>
<xsd:documentation><![CDATA[
Defines a MongoDbFactory for connecting to a specific database
]]></xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:attribute name="id" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The name of the mongo definition (by default "mongoDbFactory").]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="mongo-ref" type="mongoRef" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The reference to a Mongo instance. If not configured a default com.mongodb.Mongo instance will be created.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="dbname" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The name of the database to connect to. Default is 'db'.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="authentication-dbname" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Deprecated since 1.7 - Please use MongoClient internal authentication. The name of the authentication database to connect to. Default is 'db'.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="port" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The port to connect to MongoDB server. Default is 27017
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="host" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The host to connect to a MongoDB server. Default is localhost
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="username" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Deprecated since 1.7 - Please use MongoClient internal authentication. The username to use when connecting to a MongoDB server.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="password" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Deprecated since 1.7 - Please use MongoClient internal authentication. The password to use when connecting to a MongoDB server.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="uri" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Deprecated since 1.8 - Please use client-uri instead. The Mongo URI string.]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="client-uri" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The MongoClientURI string.]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="write-concern">
<xsd:annotation>
<xsd:documentation>
The WriteConcern that will be the default value used when asking the MongoDbFactory for a DB object
</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:union memberTypes="writeConcernEnumeration xsd:string"/>
</xsd:simpleType>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:attributeGroup name="mongo-repository-attributes">
<xsd:attribute name="mongo-template-ref" type="mongoTemplateRef" default="mongoTemplate">
<xsd:annotation>
<xsd:documentation>
The reference to a MongoTemplate. Will default to 'mongoTemplate'.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="create-query-indexes" default="false">
<xsd:annotation>
<xsd:documentation>
Enables creation of indexes for queries that get derived from the method name
and thus reference domain class properties. Defaults to false.
</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:union memberTypes="booleanType xsd:string" />
</xsd:simpleType>
</xsd:attribute>
</xsd:attributeGroup>
<xsd:element name="repositories">
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="repository:repositories">
<xsd:attributeGroup ref="mongo-repository-attributes"/>
<xsd:attributeGroup ref="repository:repository-attributes"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="mapping-converter">
<xsd:annotation>
<xsd:documentation><![CDATA[Defines a MongoConverter for getting rich mapping functionality.]]></xsd:documentation>
<xsd:appinfo>
<tool:exports type="org.springframework.data.mongodb.core.convert.MappingMongoConverter" />
</xsd:appinfo>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="custom-converters" minOccurs="0">
<xsd:annotation>
<xsd:documentation><![CDATA[
Top-level element that contains one or more custom converters to be used for mapping
domain objects to and from Mongo's DBObject]]>
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="converter" type="customConverterType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="base-package" type="xsd:string" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The name of the MappingMongoConverter instance (by default "mappingConverter").]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="base-package" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The base package in which to scan for entities annotated with @Document
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="db-factory-ref" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation>
The reference to a DbFactory.
</xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:assignable-to type="org.springframework.data.mongodb.MongoDbFactory" />
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="type-mapper-ref" type="typeMapperRef" use="optional">
<xsd:annotation>
<xsd:documentation>
The reference to a MongoTypeMapper to be used by this MappingMongoConverter.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="mapping-context-ref" type="mappingContextRef" use="optional">
<xsd:annotation>
<xsd:documentation source="org.springframework.data.mapping.model.MappingContext">
The reference to a MappingContext. Will default to 'mappingContext'.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="disable-validation" use="optional">
<xsd:annotation>
<xsd:documentation source="org.springframework.data.mongodb.core.mapping.event.ValidatingMongoEventListener">
Disables JSR-303 validation on MongoDB documents before they are saved. By default it is set to false.
</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:union memberTypes="xsd:boolean xsd:string"/>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="abbreviate-field-names" use="optional">
<xsd:annotation>
<xsd:documentation source="org.springframework.data.mongodb.core.mapping.CamelCaseAbbreviatingFieldNamingStrategy">
Enables abbreviating the field names for domain class properties to the
first character of their camel case names, e.g. fooBar -> fb. Defaults to false.
</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:union memberTypes="xsd:boolean xsd:string"/>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="field-naming-strategy-ref" type="fieldNamingStrategyRef" use="optional">
<xsd:annotation>
<xsd:documentation source="org.springframework.data.mongodb.core.mapping.FieldNamingStrategy">
The reference to a FieldNamingStrategy.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:element name="jmx">
<xsd:annotation>
<xsd:documentation><![CDATA[
Defines a JMX Model MBeans for monitoring a MongoDB server'.
]]></xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:attribute name="mongo-ref" type="mongoRef" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The name of the Mongo object that determines what server to monitor. (by default "mongo").]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:element name="auditing">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation>
<tool:exports type="org.springframework.data.mongodb.core.mapping.event.AuditingEventListener" />
<tool:exports type="org.springframework.data.auditing.IsNewAwareAuditingHandler" />
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexType>
<xsd:attributeGroup ref="repository:auditing-attributes" />
<xsd:attribute name="mapping-context-ref" type="mappingContextRef" />
</xsd:complexType>
</xsd:element>
<xsd:simpleType name="typeMapperRef">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:assignable-to type="org.springframework.data.mongodb.core.convert.MongoTypeMapper"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:union memberTypes="xsd:string"/>
</xsd:simpleType>
<xsd:simpleType name="mappingContextRef">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:assignable-to type="org.springframework.data.mapping.model.MappingContext"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:union memberTypes="xsd:string"/>
</xsd:simpleType>
<xsd:simpleType name="fieldNamingStrategyRef">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:assignable-to type="org.springframework.data.mongodb.core.mapping.FieldNamingStrategy"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:union memberTypes="xsd:string"/>
</xsd:simpleType>
<xsd:simpleType name="mongoTemplateRef">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:assignable-to type="org.springframework.data.mongodb.core.MongoTemplate"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:union memberTypes="xsd:string"/>
</xsd:simpleType>
<xsd:simpleType name="mongoRef">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:assignable-to type="org.springframework.data.mongodb.core.MongoFactoryBean"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:union memberTypes="xsd:string"/>
</xsd:simpleType>
<xsd:simpleType name="sslSocketFactoryRef">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:assignable-to type="javax.net.ssl.SSLSocketFactory"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:union memberTypes="xsd:string"/>
</xsd:simpleType>
<xsd:simpleType name="writeConcernEnumeration">
<xsd:restriction base="xsd:token">
<xsd:enumeration value="NONE" />
<xsd:enumeration value="NORMAL" />
<xsd:enumeration value="SAFE" />
<xsd:enumeration value="FSYNC_SAFE" />
<xsd:enumeration value="REPLICAS_SAFE" />
<xsd:enumeration value="JOURNAL_SAFE" />
<xsd:enumeration value="MAJORITY" />
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="readPreferenceEnumeration">
<xsd:restriction base="xsd:token">
<xsd:enumeration value="PRIMARY" />
<xsd:enumeration value="PRIMARY_PREFERRED" />
<xsd:enumeration value="SECONDARY" />
<xsd:enumeration value="SECONDARY_PREFERRED" />
<xsd:enumeration value="NEAREST" />
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="booleanType">
<xsd:restriction base="xsd:token">
<xsd:enumeration value="true" />
<xsd:enumeration value="false" />
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="mongoType">
<xsd:annotation>
<xsd:documentation><![CDATA[
Deprecated since 1.7.
]]></xsd:documentation>
</xsd:annotation>
<xsd:sequence minOccurs="0" maxOccurs="1">
<xsd:element name="options" type="optionsType">
<xsd:annotation>
<xsd:documentation><![CDATA[
The Mongo driver options
]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation>
<tool:exports type="com.mongodb.MongoOptions"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="write-concern">
<xsd:annotation>
<xsd:documentation>
The WriteConcern that will be the default value used when asking the MongoDbFactory for a DB object
</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:union memberTypes="writeConcernEnumeration xsd:string"/>
</xsd:simpleType>
</xsd:attribute>
<!-- MLP
<xsd:attributeGroup ref="writeConcern" />
-->
<xsd:attribute name="id" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The name of the mongo definition (by default "mongo").]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="port" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The port to connect to MongoDB server. Default is 27017
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="host" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The host to connect to a MongoDB server. Default is localhost
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="replica-set" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The comma delimited list of host:port entries to use for replica set/pairs.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
<xsd:complexType name="optionsType">
<xsd:annotation>
<xsd:documentation><![CDATA[
Deprecated since 1.7.
]]></xsd:documentation>
</xsd:annotation>
<xsd:attribute name="connections-per-host" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The number of connections allowed per host. Will block if run out. Default is 10. System property MONGO.POOLSIZE can override
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="threads-allowed-to-block-for-connection-multiplier" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The multiplier for connectionsPerHost for # of threads that can block. Default is 5.
If connectionsPerHost is 10, and threadsAllowedToBlockForConnectionMultiplier is 5,
then 50 threads can block more than that and an exception will be thrown.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="max-wait-time" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The max wait time of a blocking thread for a connection. Default is 12000 ms (2 minutes)
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="connect-timeout" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The connect timeout in milliseconds. 0 is default and infinite.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="socket-timeout" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The socket timeout. 0 is default and infinite.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="socket-keep-alive" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The keep alive flag, controls whether or not to have socket keep alive timeout. Defaults to false.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="auto-connect-retry" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
This controls whether or not on a connect, the system retries automatically. Default is false.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="max-auto-connect-retry-time" type="xsd:long">
<xsd:annotation>
<xsd:documentation><![CDATA[
The maximum amount of time in millisecons to spend retrying to open connection to the same server. Default is 0, which means to use the default 15s if autoConnectRetry is on.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="write-number" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
This specifies the number of servers to wait for on the write operation, and exception raising behavior. The 'w' option to the getlasterror command. Defaults to 0.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="write-timeout" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
This controls timeout for write operations in milliseconds. The 'wtimeout' option to the getlasterror command. Defaults to 0 (indefinite). Greater than zero is number of milliseconds to wait.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="write-fsync" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
This controls whether or not to fsync. The 'fsync' option to the getlasterror command. Defaults to false.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="slave-ok" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
This controls if the driver is allowed to read from secondaries or slaves. Defaults to false.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="ssl" default="false">
<xsd:annotation>
<xsd:documentation><![CDATA[
This controls if the driver should us an SSL connection. Defaults to false.
]]></xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:union memberTypes="booleanType xsd:string" />
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="ssl-socket-factory-ref" type="sslSocketFactoryRef" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The SSLSocketFactory to use for the SSL connection. If none is configured here, SSLSocketFactory#getDefault() will be used.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
<xsd:complexType name="mongoClientType">
<xsd:annotation>
<xsd:documentation><![CDATA[
Configuration options for 'MongoClient' - @since 1.7
]]></xsd:documentation>
</xsd:annotation>
<xsd:sequence minOccurs="0" maxOccurs="1">
<xsd:element name="client-options" type="clientOptionsType">
<xsd:annotation>
<xsd:documentation><![CDATA[
The Mongo driver options
]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation>
<tool:exports type="com.mongodb.MongoClientOptions"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The name of the mongo definition (by default "mongoClient").]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="port" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The port to connect to MongoDB server. Default is 27017
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="host" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The host to connect to a MongoDB server. Default is localhost
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="replica-set" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The comma delimited list of host:port entries to use for replica set/pairs.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="credentials" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The comma delimited list of username:password@database entries to use for authentication. Appending ?uri.authMechanism allows to specify the authentication challenge mechanism. If the credential you're trying to pass contains a comma itself, quote it with single quotes: '…'.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
<xsd:complexType name="clientOptionsType">
<xsd:annotation>
<xsd:documentation><![CDATA[
Configuration options for 'MongoClientOptions' - @since 1.7
]]></xsd:documentation>
</xsd:annotation>
<xsd:attribute name="description" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The MongoClient description.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="min-connections-per-host" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The minimum number of connections per host.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="connections-per-host" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The number of connections allowed per host. Will block if run out. Default is 10. System property MONGO.POOLSIZE can override.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="threads-allowed-to-block-for-connection-multiplier" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The multiplier for connectionsPerHost for # of threads that can block. Default is 5.
If connectionsPerHost is 10, and threadsAllowedToBlockForConnectionMultiplier is 5,
then 50 threads can block more than that and an exception will be thrown.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="max-wait-time" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The max wait time of a blocking thread for a connection. Default is 12000 ms (2 minutes).
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="max-connection-idle-time" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The maximum idle time for a pooled connection.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="max-connection-life-time" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The maximum life time for a pooled connection.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="connect-timeout" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The connect timeout in milliseconds. 0 is default and infinite.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="socket-timeout" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The socket timeout. 0 is default and infinite.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="socket-keep-alive" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The keep alive flag, controls whether or not to have socket keep alive timeout. Defaults to false.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="server-selection-timeout" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The server selection timeout in milliseconds, which defines how long the driver will wait for server selection to succeed before throwing an exception. Default is 30 seconds.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="read-preference">
<xsd:annotation>
<xsd:documentation><![CDATA[
The read preference.
]]></xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:union memberTypes="readPreferenceEnumeration xsd:string"/>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="write-concern">
<xsd:annotation>
<xsd:documentation><![CDATA[
The WriteConcern that will be the default value used when asking the MongoDbFactory for a DB object
]]></xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:union memberTypes="writeConcernEnumeration xsd:string"/>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="heartbeat-frequency" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
This is the frequency that the driver will attempt to determine the current state of each server in the cluster.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="min-heartbeat-frequency" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
In the event that the driver has to frequently re-check a server's availability, it will wait at least this long since the previous check to avoid wasted effort.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="heartbeat-connect-timeout" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The connect timeout for connections used for the cluster heartbeat.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="heartbeat-socket-timeout" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The socket timeout for connections used for the cluster heartbeat.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="ssl" default="false">
<xsd:annotation>
<xsd:documentation><![CDATA[
This controls if the driver should us an SSL connection. Defaults to false.
]]></xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:union memberTypes="booleanType xsd:string" />
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="ssl-socket-factory-ref" type="sslSocketFactoryRef" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The SSLSocketFactory to use for the SSL connection. If none is configured here, SSLSocketFactory#getDefault() will be used.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
<xsd:group name="beanElementGroup">
<xsd:choice>
<xsd:element ref="beans:bean"/>
<xsd:element ref="beans:ref"/>
</xsd:choice>
</xsd:group>
<xsd:complexType name="customConverterType">
<xsd:annotation>
<xsd:documentation><![CDATA[
Element defining a custom converter.
]]></xsd:documentation>
</xsd:annotation>
<xsd:group ref="beanElementGroup" minOccurs="0" maxOccurs="1"/>
<xsd:attribute name="ref" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
A reference to a custom converter.
</xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
<xsd:simpleType name="converterRef">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:assignable-to type="org.springframework.data.mongodb.core.convert.MongoConverter"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:union memberTypes="xsd:string"/>
</xsd:simpleType>
<xsd:element name="template">
<xsd:annotation>
<xsd:documentation><![CDATA[
Defines a MongoDbFactory for connecting to a specific database
]]></xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:attribute name="id" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The name of the mongo definition (by default "mongoDbFactory").]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="converter-ref" type="converterRef" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The reference to a Mongoconverter instance.
]]>
</xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:assignable-to type="org.springframework.data.mongodb.core.convert.MongoConverter"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="db-factory-ref" type="xsd:string"
use="optional">
<xsd:annotation>
<xsd:documentation>
The reference to a DbFactory.
</xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:assignable-to
type="org.springframework.data.mongodb.MongoDbFactory" />
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="write-concern">
<xsd:annotation>
<xsd:documentation>
The WriteConcern that will be the default value used when asking the MongoDbFactory for a DB object
</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:union memberTypes="writeConcernEnumeration xsd:string"/>
</xsd:simpleType>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:element name="gridFsTemplate">
<xsd:annotation>
<xsd:documentation><![CDATA[
Defines a MongoDbFactory for connecting to a specific database
]]></xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:attribute name="id" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The name of the mongo definition (by default "mongoDbFactory").]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="converter-ref" type="converterRef" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The reference to a Mongoconverter instance.
]]>
</xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:assignable-to type="org.springframework.data.mongodb.core.convert.MongoConverter"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="db-factory-ref" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation>
The reference to a DbFactory.
</xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:assignable-to type="org.springframework.data.mongodb.MongoDbFactory" />
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="bucket" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The GridFs bucket string.]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
</xsd:schema>

View File

@@ -19,6 +19,7 @@ import static org.hamcrest.collection.IsIterableContainingInOrder.*;
import static org.hamcrest.core.Is.*;
import static org.hamcrest.core.IsInstanceOf.*;
import static org.junit.Assert.*;
import static org.junit.Assume.*;
import org.junit.Before;
import org.junit.Test;
@@ -28,6 +29,8 @@ import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.mongodb.util.MongoClientVersion;
import org.springframework.test.util.ReflectionTestUtils;
import com.mongodb.MongoClient;
import com.mongodb.MongoCredential;
@@ -36,7 +39,7 @@ import com.mongodb.WriteConcern;
/**
* Integration tests for {@link MongoClientParser}.
*
*
* @author Christoph Strobl
*/
public class MongoClientParserIntegrationTests {
@@ -113,4 +116,24 @@ public class MongoClientParserIntegrationTests {
context.close();
}
}
@Test // DATAMONGO-1620
public void createsMongoClientWithServerSelectionTimeoutCorrectly() {
assumeThat(MongoClientVersion.isMongo3Driver(), is(true));
reader.loadBeanDefinitions(new ClassPathResource("namespace/mongoClient-bean.xml"));
AbstractApplicationContext context = new GenericApplicationContext(factory);
context.refresh();
try {
MongoClient client = context.getBean("mongo-client-with-server-selection-timeout", MongoClient.class);
assertThat(ReflectionTestUtils.getField(client.getMongoClientOptions(), "serverSelectionTimeout"),
is((Object) 100));
} finally {
context.close();
}
}
}

View File

@@ -52,6 +52,8 @@ import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
import org.springframework.data.mongodb.core.convert.QueryMapper;
import org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator;
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
import org.springframework.data.mongodb.core.mapping.event.AbstractMongoEventListener;
import org.springframework.data.mongodb.core.mapping.event.BeforeConvertEvent;
import org.springframework.data.mongodb.core.mapreduce.MapReduceOptions;
import org.springframework.data.mongodb.core.query.BasicQuery;
import org.springframework.data.mongodb.core.query.Criteria;
@@ -72,6 +74,7 @@ import com.mongodb.MapReduceOutput;
import com.mongodb.Mongo;
import com.mongodb.MongoException;
import com.mongodb.ReadPreference;
import com.mongodb.WriteResult;
/**
* Unit tests for {@link MongoTemplate}.
@@ -325,8 +328,8 @@ public class MongoTemplateUnitTests extends MongoOperationsUnitTests {
@Test // DATAMONGO-1166
public void aggregateShouldHonorReadPreferenceWhenSet() {
when(db.command(Mockito.any(DBObject.class), Mockito.any(ReadPreference.class))).thenReturn(
mock(CommandResult.class));
when(db.command(Mockito.any(DBObject.class), Mockito.any(ReadPreference.class)))
.thenReturn(mock(CommandResult.class));
when(db.command(Mockito.any(DBObject.class))).thenReturn(mock(CommandResult.class));
template.setReadPreference(ReadPreference.secondary());
@@ -338,8 +341,8 @@ public class MongoTemplateUnitTests extends MongoOperationsUnitTests {
@Test // DATAMONGO-1166
public void aggregateShouldIgnoreReadPreferenceWhenNotSet() {
when(db.command(Mockito.any(DBObject.class), Mockito.any(ReadPreference.class))).thenReturn(
mock(CommandResult.class));
when(db.command(Mockito.any(DBObject.class), Mockito.any(ReadPreference.class)))
.thenReturn(mock(CommandResult.class));
when(db.command(Mockito.any(DBObject.class))).thenReturn(mock(CommandResult.class));
template.aggregate(Aggregation.newAggregation(Aggregation.unwind("foo")), "collection-1", Wrapper.class);
@@ -350,8 +353,8 @@ public class MongoTemplateUnitTests extends MongoOperationsUnitTests {
@Test // DATAMONGO-1166
public void geoNearShouldHonorReadPreferenceWhenSet() {
when(db.command(Mockito.any(DBObject.class), Mockito.any(ReadPreference.class))).thenReturn(
mock(CommandResult.class));
when(db.command(Mockito.any(DBObject.class), Mockito.any(ReadPreference.class)))
.thenReturn(mock(CommandResult.class));
when(db.command(Mockito.any(DBObject.class))).thenReturn(mock(CommandResult.class));
template.setReadPreference(ReadPreference.secondary());
@@ -364,8 +367,8 @@ public class MongoTemplateUnitTests extends MongoOperationsUnitTests {
@Test // DATAMONGO-1166
public void geoNearShouldIgnoreReadPreferenceWhenNotSet() {
when(db.command(Mockito.any(DBObject.class), Mockito.any(ReadPreference.class))).thenReturn(
mock(CommandResult.class));
when(db.command(Mockito.any(DBObject.class), Mockito.any(ReadPreference.class)))
.thenReturn(mock(CommandResult.class));
when(db.command(Mockito.any(DBObject.class))).thenReturn(mock(CommandResult.class));
NearQuery query = NearQuery.near(new Point(1, 1));
@@ -465,6 +468,33 @@ public class MongoTemplateUnitTests extends MongoOperationsUnitTests {
assertThat(captor.getValue().getLimit(), is(1000));
}
@Test // DATAMONGO-1639
public void beforeConvertEventForUpdateSeesNextVersion() {
final VersionedEntity entity = new VersionedEntity();
entity.id = 1;
entity.version = 0;
GenericApplicationContext context = new GenericApplicationContext();
context.refresh();
context.addApplicationListener(new AbstractMongoEventListener<VersionedEntity>() {
@Override
public void onBeforeConvert(BeforeConvertEvent<VersionedEntity> event) {
assertThat(event.getSource().version, is(1));
}
});
template.setApplicationContext(context);
MongoTemplate spy = Mockito.spy(template);
doReturn(mock(WriteResult.class)).when(spy).doUpdate(anyString(), Mockito.any(Query.class),
Mockito.any(Update.class), Mockito.any(Class.class), anyBoolean(), anyBoolean());
spy.save(entity);
}
class AutogenerateableId {
@Id BigInteger id;

View File

@@ -31,6 +31,7 @@ import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bson.types.ObjectId;
import org.junit.Before;
@@ -63,7 +64,7 @@ import com.mongodb.DBRef;
/**
* Unit tests for {@link DbRefMappingMongoConverter}.
*
*
* @author Oliver Gierke
* @author Thomas Darimont
* @author Christoph Strobl
@@ -548,6 +549,28 @@ public class DbRefMappingMongoConverterUnitTests {
verify(converterSpy, never()).readRef(Mockito.any(DBRef.class));
}
@Test // DATAMONGO-1666
public void shouldBulkFetchSetOfReferencesForConstructorCreation() {
String id1 = "1";
String id2 = "2";
String value = "val";
MappingMongoConverter converterSpy = spy(converter);
doReturn(
Arrays.asList(new BasicDBObject("_id", id1).append("value", value), new BasicDBObject("_id", id2).append("value", value)))
.when(converterSpy).bulkReadRefs(anyListOf(DBRef.class));
BasicDBObject document = new BasicDBObject("dbRefToInterface",
Arrays.asList(new DBRef("lazyDbRefTarget", "1"), new DBRef("lazyDbRefTarget", "2")));
ClassWithDbRefSetConstructor result = converterSpy.read(ClassWithDbRefSetConstructor.class, document);
assertThat(result.dbRefToInterface, is(instanceOf(Set.class)));
verify(converterSpy, never()).readRef(Mockito.any(DBRef.class));
}
@Test // DATAMONGO-1194
public void shouldFallbackToOneByOneFetchingWhenElementsInListOfReferencesPointToDifferentCollections() {
@@ -673,6 +696,15 @@ public class DbRefMappingMongoConverterUnitTests {
lazy = true) LazyDbRefTargetWithPeristenceConstructorWithoutDefaultConstructor dbRefToConcreteTypeWithPersistenceConstructorWithoutDefaultConstructor;
}
static class ClassWithDbRefSetConstructor {
final @org.springframework.data.mongodb.core.mapping.DBRef Set<LazyDbRefTarget> dbRefToInterface;
public ClassWithDbRefSetConstructor(Set<LazyDbRefTarget> dbRefToInterface) {
this.dbRefToInterface = dbRefToInterface;
}
}
static class SerializableClassWithLazyDbRefs implements Serializable {
private static final long serialVersionUID = 1L;
@@ -780,7 +812,7 @@ public class DbRefMappingMongoConverterUnitTests {
super(id, value);
}
/*
/*
* (non-Javadoc)
* @see java.lang.Object#toString()
*/

View File

@@ -0,0 +1,124 @@
/*
* Copyright 2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.mongodb.core.mapping.event;
import static org.hamcrest.core.StringStartsWith.*;
import static org.junit.Assert.*;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.read.ListAppender;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.LoggerFactory;
import com.mongodb.BasicDBObject;
/**
* Tests for {@link LoggingEventListener}.
*
* @author Christoph Strobl
* @author Mark Paluch
*/
public class LoggingEventListenerTests {
ListAppender<ILoggingEvent> appender;
ch.qos.logback.classic.Logger logger;
LoggingEventListener listener;
@Before
public void setUp() {
appender = new ListAppender<ILoggingEvent>();
// set log level for LoggingEventListener to "info" and set up an appender capturing events.
logger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(LoggingEventListener.class);
logger.setAdditive(false);
logger.setLevel(Level.INFO);
logger.addAppender(appender);
appender.start();
listener = new LoggingEventListener();
}
@After
public void tearDown() {
// cleanup
if (logger != null) {
logger.detachAppender(appender);
logger.setAdditive(true);
logger.setLevel(null);
}
if (appender != null) {
appender.stop();
}
}
@Test // DATAMONGO-1645
public void shouldSerializeAfterConvertEventCorrectly() {
listener.onAfterConvert(new AfterConvertEvent<Object>(new BasicDBObject("foo", new Foo()), this, "collection"));
assertThat(appender.list.get(0).getFormattedMessage(), startsWith("onAfterConvert: { \"foo\""));
}
@Test // DATAMONGO-1645
public void shouldSerializeBeforeSaveEventEventCorrectly() {
listener.onBeforeSave(new BeforeSaveEvent<Object>(new Foo(), new BasicDBObject("foo", new Foo()), "collection"));
assertThat(appender.list.get(0).getFormattedMessage(),
startsWith("onBeforeSave: org.springframework.data.mongodb.core."));
}
@Test // DATAMONGO-1645
public void shouldSerializeAfterSaveEventEventCorrectly() {
listener.onAfterSave(new AfterSaveEvent<Object>(new Foo(), new BasicDBObject("foo", new Foo()), "collection"));
assertThat(appender.list.get(0).getFormattedMessage(),
startsWith("onAfterSave: org.springframework.data.mongodb.core."));
}
@Test // DATAMONGO-1645
public void shouldSerializeBeforeDeleteEventEventCorrectly() {
listener
.onBeforeDelete(new BeforeDeleteEvent<Object>(new BasicDBObject("foo", new Foo()), Object.class, "collection"));
assertThat(appender.list.get(0).getFormattedMessage(), startsWith("onBeforeDelete: { \"foo\""));
}
@Test // DATAMONGO-1645
public void shouldSerializeAfterDeleteEventEventCorrectly() {
listener
.onAfterDelete(new AfterDeleteEvent<Object>(new BasicDBObject("foo", new Foo()), Object.class, "collection"));
assertThat(appender.list.get(0).getFormattedMessage(), startsWith("onAfterDelete: { \"foo\""));
}
static class Foo {
}
}

View File

@@ -33,11 +33,12 @@ import org.springframework.data.mongodb.core.SpecialDoc;
/**
* Unit tests for {@link Query}.
*
*
* @author Thomas Risberg
* @author Oliver Gierke
* @author Patryk Wasik
* @author Thomas Darimont
* @author Christoph Strobl
*/
public class QueryTests {
@@ -204,4 +205,20 @@ public class QueryTests {
assertThat(query.getRestrictedTypes().size(), is(1));
assertThat(query.getRestrictedTypes(), hasItems(Arrays.asList(SpecialDoc.class).toArray(new Class<?>[0])));
}
@Test // DATAMONGO-1421
public void addCriteriaForSamePropertyMultipleTimesShouldThrowAndSafelySerializeErrorMessage() {
exception.expect(InvalidMongoDbApiUsageException.class);
exception.expectMessage("second 'value' criteria");
exception.expectMessage("already contains '{ \"value\" : { $java : VAL_1 } }'");
Query query = new Query();
query.addCriteria(where("value").is(EnumType.VAL_1));
query.addCriteria(where("value").is(EnumType.VAL_2));
}
enum EnumType {
VAL_1, VAL_2
}
}

View File

@@ -15,4 +15,9 @@
<mongo:mongo-client />
<!-- DATAMONGO-1620 -->
<mongo:mongo-client id="mongo-client-with-server-selection-timeout">
<mongo:client-options server-selection-timeout="100" />
</mongo:mongo-client>
</beans>

View File

@@ -1732,7 +1732,7 @@ Note that the aggregation operations not listed here are currently not supported
[[mongo.aggregation.projection]]
=== Projection Expressions
Projection expressions are used to define the fields that are the outcome of a particular aggregation step. Projection expressions can be defined via the `project` method of the `Aggregate` class either by passing a list of ``String``'s or an aggregation framework `Fields` object. The projection can be extended with additional fields through a fluent API via the `and(String)` method and aliased via the `as(String)` method.
Projection expressions are used to define the fields that are the outcome of a particular aggregation step. Projection expressions can be defined via the `project` method of the `Aggregation` class either by passing a list of ``String``'s or an aggregation framework `Fields` object. The projection can be extended with additional fields through a fluent API via the `and(String)` method and aliased via the `as(String)` method.
Note that one can also define fields with aliases via the static factory method `Fields.field` of the aggregation framework that can then be used to construct a new `Fields` instance. References to projected fields in later aggregation stages are only valid by using the field name of included fields or their alias of aliased or newly defined fields. Fields not included in the projection cannot be referenced in later aggregation stages.
.Projection expression examples

View File

@@ -1,6 +1,95 @@
Spring Data MongoDB Changelog
=============================
Changes in version 1.10.3.RELEASE (2017-04-19)
----------------------------------------------
* DATAMONGO-1669 - Release 1.10.3 (Ingalls SR3).
Changes in version 1.9.9.RELEASE (2017-04-19)
---------------------------------------------
* DATAMONGO-1662 - Section "Projection Expressions" contains error "Aggregate".
* DATAMONGO-1645 - RuntimeException when logging BeforeDeleteEvent and AfterDeleteEvent.
* DATAMONGO-1639 - BeforeConvertEvent now sees old version values for update of entities.
* DATAMONGO-1634 - Release 1.9.9 (Hopper SR9).
* DATAMONGO-1421 - Repository with Enum argument: json can't serialize type.
Changes in version 1.10.2.RELEASE (2017-04-19)
----------------------------------------------
* DATAMONGO-1666 - Constructor creation with bulk fetching of DBRefs uses List instead of collection type.
* DATAMONGO-1662 - Section "Projection Expressions" contains error "Aggregate".
* DATAMONGO-1645 - RuntimeException when logging BeforeDeleteEvent and AfterDeleteEvent.
* DATAMONGO-1639 - BeforeConvertEvent now sees old version values for update of entities.
* DATAMONGO-1633 - Release 1.10.2 (Ingalls SR2).
* DATAMONGO-1620 - Not able to set serverSelectionTimeout on MongoClientOptions using MongoClientOptionsFactoryBean.
* DATAMONGO-1421 - Repository with Enum argument: json can't serialize type.
Changes in version 2.0.0.M2 (2017-04-04)
----------------------------------------
* DATAMONGO-1656 - Upgrade to MongoDB Driver 3.4.2 and Reactive Streams Driver 1.3.0.
* DATAMONGO-1655 - Remove obsolete build profiles.
* DATAMONGO-1648 - Rename getRepositoryFactoryClassName to getRepositoryFactoryBeanClassName.
* DATAMONGO-1647 - Use IdentifierAccessor.getRequiredIdentifier() in MongoTemplate.doSaveVersioned(…).
* DATAMONGO-1645 - RuntimeException when logging BeforeDeleteEvent and AfterDeleteEvent.
* DATAMONGO-1643 - Add namespace xsd for 2.x.
* DATAMONGO-1641 - Remove formatting config from the repository.
* DATAMONGO-1639 - BeforeConvertEvent now sees old version values for update of entities.
* DATAMONGO-1637 - Add support for aggregation result streaming.
* DATAMONGO-1620 - Not able to set serverSelectionTimeout on MongoClientOptions using MongoClientOptionsFactoryBean.
* DATAMONGO-1617 - IDs with non-autogeneratable type cannot be assigned automatically with custom event listeners.
* DATAMONGO-1610 - Support RxJava 2 repositories.
* DATAMONGO-1608 - NullPointerException with null argument when using IgnoreCase.
* DATAMONGO-1607 - Class Cast Exception when retrieve data Point with value equal integer.
* DATAMONGO-1605 - All SPEL values are converted to String.
* DATAMONGO-1603 - @Query Annotation Placeholder Issue.
* DATAMONGO-1602 - Remove references to single-argument assertion methods of Spring.
* DATAMONGO-1600 - GraphLookupOperationBuilder is not visible.
* DATAMONGO-1596 - Reference to wrong annotation in cross-store reference documentation.
* DATAMONGO-1594 - Update "whats new" section in reference documentation.
* DATAMONGO-1590 - Entity new detection doesn't consider Persistable.isNew().
* DATAMONGO-1589 - Update project documentation with the CLA tool integration.
* DATAMONGO-1588 - Repository will not accept Point subclass in spatial query.
* DATAMONGO-1587 - Migrate ticket references in test code to Spring Framework style.
* DATAMONGO-1586 - TypeBasedAggregationOperationContext.getReferenceFor(…) exposes fields with their leaf property name.
* DATAMONGO-1585 - Aggregation sort references target field of projected and aliased fields.
* DATAMONGO-1581 - ReactiveMongoRepositoryConfigurationExtension should be public.
* DATAMONGO-1578 - Add missing @Test annotation to ProjectionOperationUnitTests.
* DATAMONGO-1577 - Fix Reference and JavaDoc spelling issues.
* DATAMONGO-1576 - AbstractMongoEventListener methods not called when working with member fields.
* DATAMONGO-1575 - Treat String replacement values in StringBased queries as such unless they are SpEL expressions.
* DATAMONGO-1567 - Upgrade to a newer JDK version on TravisCI.
* DATAMONGO-1566 - Adapt API in RepositoryFactoryBeanSupport implementation.
* DATAMONGO-1565 - Placeholders in manually defined queries not escaped properly.
* DATAMONGO-1564 - Split up AggregationExpressions.
* DATAMONGO-1559 - Migrate reactive tests from TestSubscriber to StepVerifier.
* DATAMONGO-1558 - Upgrade travis-ci profile to MongoDB 3.4.
* DATAMONGO-1552 - Add $facet, $bucket and $bucketAuto aggregation stages.
* DATAMONGO-1551 - Add $graphLookup aggregation stage.
* DATAMONGO-1550 - Add $replaceRoot aggregation stage.
* DATAMONGO-1549 - Add $count aggregation stage.
* DATAMONGO-1548 - Add new MongoDB 3.4 aggregation operators.
* DATAMONGO-1547 - Register repository factory in spring.factories for multi-store support.
* DATAMONGO-1546 - Switch to new way of registering custom Jackson modules.
* DATAMONGO-1542 - Refactor CondOperator and IfNullOperator to children of AggregationExpressions.
* DATAMONGO-1540 - Add support for $map to aggregation.
* DATAMONGO-1539 - Add dedicated annotations for manually declared count and delete queries.
* DATAMONGO-1538 - Add support for $let to aggregation.
* DATAMONGO-1536 - Add missing aggregation operators.
* DATAMONGO-1535 - Release 2.0 M2 (Kay).
Changes in version 1.9.8.RELEASE (2017-03-02)
---------------------------------------------
* DATAMONGO-1608 - NullPointerException with null argument when using IgnoreCase.
* DATAMONGO-1607 - Class Cast Exception when retrieve data Point with value equal integer.
* DATAMONGO-1605 - All SPEL values are converted to String.
* DATAMONGO-1603 - @Query Annotation Placeholder Issue.
* DATAMONGO-1602 - Remove references to single-argument assertion methods of Spring.
* DATAMONGO-1597 - Release 1.9.8 (Hopper SR8).
Changes in version 1.10.1.RELEASE (2017-03-02)
----------------------------------------------
* DATAMONGO-1608 - NullPointerException with null argument when using IgnoreCase.

View File

@@ -1,4 +1,4 @@
Spring Data MongoDB 1.10.1
Spring Data MongoDB 1.10.3
Copyright (c) [2010-2015] Pivotal Software, Inc.
This product is licensed to you under the Apache License, Version 2.0 (the "License").