List of usage examples for org.springframework.data.mongodb.core WriteResultChecking NONE
WriteResultChecking NONE
To view the source code for org.springframework.data.mongodb.core WriteResultChecking NONE.
Click Source Link
From source file:org.springframework.data.mongodb.core.MongoTemplate.java
/** * Checks and handles any errors.//from w w w .ja va 2 s .c o m * <p/> * Current implementation logs errors. Future version may make this configurable to log warning, errors or throw * exception. */ protected void handleAnyWriteResultErrors(WriteResult wr, DBObject query, String operation) { if (WriteResultChecking.NONE == this.writeResultChecking) { return; } String error = wr.getError(); if (error != null) { String message; if (operation.equals("insert") || operation.equals("save")) { // assuming the insert operations will begin with insert string message = String.format("Insert/Save for %s failed: %s", query, error); } else if (operation.equals("insert_list")) { message = String.format("Insert list failed: %s", error); } else { message = String.format("Execution of %s%s failed: %s", operation, query == null ? "" : "' using '" + query.toString() + "' query", error); } if (WriteResultChecking.EXCEPTION == this.writeResultChecking) { throw new DataIntegrityViolationException(message); } else { LOGGER.error(message); return; } } }