|
18 | 18 | import java.util.regex.Matcher;
|
19 | 19 | import java.util.regex.Pattern;
|
20 | 20 |
|
21 |
| -import org.bson.types.ObjectId; |
22 | 21 | import org.slf4j.Logger;
|
23 | 22 | import org.slf4j.LoggerFactory;
|
24 | 23 | import org.springframework.data.mongodb.core.MongoOperations;
|
25 | 24 | import org.springframework.data.mongodb.core.query.BasicQuery;
|
26 | 25 | import org.springframework.data.mongodb.core.query.Query;
|
27 | 26 |
|
| 27 | +import com.mongodb.util.JSON; |
| 28 | + |
28 | 29 | /**
|
29 | 30 | * Query to use a plain JSON String to create the {@link Query} to actually execute.
|
30 | 31 | *
|
@@ -55,12 +56,9 @@ public StringBasedMongoQuery(MongoQueryMethod method, MongoOperations mongoOpera
|
55 | 56 | }
|
56 | 57 |
|
57 | 58 | /*
|
58 |
| - * (non-Javadoc) |
59 |
| - * |
60 |
| - * @see |
61 |
| - * org.springframework.data.mongodb.repository.AbstractMongoQuery#createQuery(org.springframework.data. |
62 |
| - * repository.query.SimpleParameterAccessor, org.springframework.data.mongodb.core.core.support.convert.MongoConverter) |
63 |
| - */ |
| 59 | + * (non-Javadoc) |
| 60 | + * @see org.springframework.data.mongodb.repository.query.AbstractMongoQuery#createQuery(org.springframework.data.mongodb.repository.query.ConvertingParameterAccessor) |
| 61 | + */ |
64 | 62 | @Override
|
65 | 63 | protected Query createQuery(ConvertingParameterAccessor accessor) {
|
66 | 64 |
|
@@ -99,17 +97,6 @@ private String replacePlaceholders(String input, ConvertingParameterAccessor acc
|
99 | 97 | }
|
100 | 98 |
|
101 | 99 | private String getParameterWithIndex(ConvertingParameterAccessor accessor, int index) {
|
102 |
| - |
103 |
| - Object parameter = accessor.getBindableValue(index); |
104 |
| - |
105 |
| - if (parameter == null) { |
106 |
| - return "null"; |
107 |
| - } else if (parameter instanceof String || parameter.getClass().isEnum()) { |
108 |
| - return String.format("\"%s\"", parameter); |
109 |
| - } else if (parameter instanceof ObjectId) { |
110 |
| - return String.format("{ '$oid' : '%s' }", parameter); |
111 |
| - } |
112 |
| - |
113 |
| - return parameter.toString(); |
| 100 | + return JSON.serialize(accessor.getBindableValue(index)); |
114 | 101 | }
|
115 | 102 | }
|
0 commit comments