remove a some ctors in mongo template
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
package org.springframework.data.document.mongodb;
|
||||
|
||||
import com.mongodb.MongoException;
|
||||
import com.mongodb.MongoException.CursorNotFound;
|
||||
import com.mongodb.MongoException.DuplicateKey;
|
||||
import com.mongodb.MongoException.Network;
|
||||
import com.mongodb.MongoInternalException;
|
||||
@@ -52,11 +53,14 @@ public class MongoExceptionTranslator implements PersistenceExceptionTranslator
|
||||
|
||||
// All other MongoExceptions
|
||||
if (ex instanceof DuplicateKey) {
|
||||
return new DataIntegrityViolationException(ex.getMessage(), ex);
|
||||
return new DuplicateKeyException(ex.getMessage(), ex);
|
||||
}
|
||||
if (ex instanceof Network) {
|
||||
return new DataAccessResourceFailureException(ex.getMessage(), ex);
|
||||
}
|
||||
if (ex instanceof CursorNotFound) {
|
||||
return new DataAccessResourceFailureException(ex.getMessage(), ex);
|
||||
}
|
||||
if (ex instanceof MongoException) {
|
||||
int code = ((MongoException)ex).getCode();
|
||||
if (code == 11000 || code == 11001) {
|
||||
|
||||
@@ -96,8 +96,8 @@ public class MongoTemplateTests {
|
||||
@Test
|
||||
public void updateFailure() throws Exception {
|
||||
|
||||
MongoTemplate mongoTemplate = new MongoTemplate(template.getDb().getMongo(), "test", "people",
|
||||
new WriteConcern(), WriteResultChecking.EXCEPTION);
|
||||
MongoTemplate mongoTemplate = new MongoTemplate(template.getDb().getMongo(), "test", "people");
|
||||
mongoTemplate.setWriteResultChecking(WriteResultChecking.EXCEPTION);
|
||||
|
||||
Person person = new Person("Oliver2");
|
||||
person.setAge(25);
|
||||
|
||||
Reference in New Issue
Block a user