1
1
/*
2
- * Copyright 2011-2015 the original author or authors.
2
+ * Copyright 2011-2016 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
37
37
/**
38
38
* @author Thomas Risberg
39
39
* @author Oliver Gierke
40
+ * @author Alex Vengrovsk
41
+ * @author Mark Paluch
40
42
*/
41
43
public class MongoChangeSetPersister implements ChangeSetPersister <Object > {
42
44
@@ -76,14 +78,14 @@ public void getPersistentState(Class<? extends ChangeSetBacked> entityClass, Obj
76
78
dbk .put (ENTITY_ID , id );
77
79
dbk .put (ENTITY_CLASS , entityClass .getName ());
78
80
if (log .isDebugEnabled ()) {
79
- log .debug ("Loading MongoDB data for " + dbk );
81
+ log .debug ("Loading MongoDB data for {}" , dbk );
80
82
}
81
83
mongoTemplate .execute (collName , new CollectionCallback <Object >() {
82
84
public Object doInCollection (DBCollection collection ) throws MongoException , DataAccessException {
83
85
for (DBObject dbo : collection .find (dbk )) {
84
86
String key = (String ) dbo .get (ENTITY_FIELD_NAME );
85
87
if (log .isDebugEnabled ()) {
86
- log .debug ("Processing key: " + key );
88
+ log .debug ("Processing key: {}" , key );
87
89
}
88
90
if (!changeSet .getValues ().containsKey (key )) {
89
91
String className = (String ) dbo .get (ENTITY_FIELD_CLASS );
@@ -94,7 +96,7 @@ public Object doInCollection(DBCollection collection) throws MongoException, Dat
94
96
Class <?> clazz = ClassUtils .resolveClassName (className , ClassUtils .getDefaultClassLoader ());
95
97
Object value = mongoTemplate .getConverter ().read (clazz , dbo );
96
98
if (log .isDebugEnabled ()) {
97
- log .debug ("Adding to ChangeSet: " + key );
99
+ log .debug ("Adding to ChangeSet: {}" , key );
98
100
}
99
101
changeSet .set (key , value );
100
102
}
@@ -109,9 +111,9 @@ public Object doInCollection(DBCollection collection) throws MongoException, Dat
109
111
* @see org.springframework.data.crossstore.ChangeSetPersister#getPersistentId(org.springframework.data.crossstore.ChangeSetBacked, org.springframework.data.crossstore.ChangeSet)
110
112
*/
111
113
public Object getPersistentId (ChangeSetBacked entity , ChangeSet cs ) throws DataAccessException {
112
- if (log .isDebugEnabled ()) {
113
- log .debug ("getPersistentId called on " + entity );
114
- }
114
+ if (log .isDebugEnabled ()) {
115
+ log .debug ("getPersistentId called on {}" , entity );
116
+ }
115
117
if (entityManagerFactory == null ) {
116
118
throw new DataAccessResourceFailureException ("EntityManagerFactory cannot be null" );
117
119
}
@@ -130,7 +132,7 @@ public Object persistState(ChangeSetBacked entity, ChangeSet cs) throws DataAcce
130
132
}
131
133
132
134
if (log .isDebugEnabled ()) {
133
- log .debug ("Flush: changeset: " + cs .getValues ());
135
+ log .debug ("Flush: changeset: {}" , cs .getValues ());
134
136
}
135
137
136
138
String collName = getCollectionNameForEntity (entity .getClass ());
@@ -152,7 +154,7 @@ public DBObject doInCollection(DBCollection collection) throws MongoException, D
152
154
});
153
155
if (value == null ) {
154
156
if (log .isDebugEnabled ()) {
155
- log .debug ("Flush: removing: " + dbQuery );
157
+ log .debug ("Flush: removing: {}" , dbQuery );
156
158
}
157
159
mongoTemplate .execute (collName , new CollectionCallback <Object >() {
158
160
public Object doInCollection (DBCollection collection ) throws MongoException , DataAccessException {
@@ -164,7 +166,7 @@ public Object doInCollection(DBCollection collection) throws MongoException, Dat
164
166
final DBObject dbDoc = new BasicDBObject ();
165
167
dbDoc .putAll (dbQuery );
166
168
if (log .isDebugEnabled ()) {
167
- log .debug ("Flush: saving: " + dbQuery );
169
+ log .debug ("Flush: saving: {}" , dbQuery );
168
170
}
169
171
mongoTemplate .getConverter ().write (value , dbDoc );
170
172
dbDoc .put (ENTITY_FIELD_CLASS , value .getClass ().getName ());
0 commit comments