|
|
|
@ -493,25 +493,32 @@ public class MongoQueryMethod extends QueryMethod { |
|
|
|
if (isCollectionQuery() || isScrollQuery() || isSliceQuery() || isPageQuery() || isGeoNearQuery() |
|
|
|
if (isCollectionQuery() || isScrollQuery() || isSliceQuery() || isPageQuery() || isGeoNearQuery() |
|
|
|
|| !isNumericOrVoidReturnValue()) { //
|
|
|
|
|| !isNumericOrVoidReturnValue()) { //
|
|
|
|
throw new IllegalStateException( |
|
|
|
throw new IllegalStateException( |
|
|
|
String.format("Update method may be void or return a numeric value (the number of updated documents)." |
|
|
|
String.format( |
|
|
|
+ "Offending method: %s", method)); |
|
|
|
"Update method may be void or return a numeric value (the number of updated documents)." |
|
|
|
|
|
|
|
+ " Offending Method: %s.%s", |
|
|
|
|
|
|
|
ClassUtils.getShortName(method.getDeclaringClass()), method.getName())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (hasAnnotatedUpdate()) { // must define either an update or an update pipeline
|
|
|
|
if (hasAnnotatedUpdate()) { // must define either an update or an update pipeline
|
|
|
|
if (!StringUtils.hasText(getUpdateSource().update()) && ObjectUtils.isEmpty(getUpdateSource().pipeline())) { |
|
|
|
if (!StringUtils.hasText(getUpdateSource().update()) && ObjectUtils.isEmpty(getUpdateSource().pipeline())) { |
|
|
|
throw new IllegalStateException( |
|
|
|
throw new IllegalStateException( |
|
|
|
String.format("Update method must define either 'Update#update' or 'Update#pipeline' attribute;" |
|
|
|
String.format( |
|
|
|
+ " Offending method: %s", method)); |
|
|
|
"Update method must define either 'Update#update' or 'Update#pipeline' attribute;" |
|
|
|
|
|
|
|
+ " Offending Method: %s.%s", |
|
|
|
|
|
|
|
ClassUtils.getShortName(method.getDeclaringClass()), method.getName())); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (hasAnnotatedAggregation()) { |
|
|
|
if (hasAnnotatedAggregation()) { |
|
|
|
for (String stage : getAnnotatedAggregation()) { |
|
|
|
for (String stage : getAnnotatedAggregation()) { |
|
|
|
if (BsonUtils.isJsonArray(stage)) { |
|
|
|
if (BsonUtils.isJsonArray(stage)) { |
|
|
|
throw new IllegalStateException(""" |
|
|
|
throw new IllegalStateException(String.format( |
|
|
|
Invalid aggregation pipeline. Please split Aggregation.pipeline from "[{...}, {...}]" to "{...}", "{...}". |
|
|
|
""" |
|
|
|
Offending Method: %s.%s |
|
|
|
Invalid aggregation pipeline. Please split the definition from @Aggregation("[{...}, {...}]") to @Aggregation({ "{...}", "{...}" }). |
|
|
|
""".formatted(method.getDeclaringClass().getSimpleName(), method.getName())); |
|
|
|
Offending Method: %s.%s |
|
|
|
|
|
|
|
""", |
|
|
|
|
|
|
|
ClassUtils.getShortName(method.getDeclaringClass()), method.getName())); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|