Reputation: 330
I have a project which uses Spring Data to connect to a MongoDB database (version 1.8.0), currently I am trying to create an Aggregation query but its failing when I use any of the following operators: gt, gte, lt,lte
My aggregation query looks like this:
TypedAggregation<Rawdata> aggregation = newAggregation(Rawdata.class,
match(Criteria.where("value").gte(value)),
group("genotypeName","genotypeId","value"),
sort(Sort.Direction.ASC, "value"),
limit(total)
);
AggregationResults<Rawdata> result = mongoTemplate.aggregate(aggregation, Rawdata.class);
When I run it, I get the following exception:
org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.IllegalAccessError: org/springframework/beans/PropertyMatches
org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1287)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:961)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
I am sure the problem is in the gte
operator because if I replace it for is
, my query runs with no issues.
I debugged up to org.springframework.data.util.TypeDiscoverer
and it seems like Spring is trying to search inside my Rawdata class a field named $gte
to determinate its type.
Any help will be very appreciated.
EDIT: As I mentioned, Spring seems to be looking for a property named $gte
in my Rawdata class, after adding this property my aggregation query works.
So far my code is working but it looks to me like something is wrong.
Upvotes: 0
Views: 808
Reputation: 330
After tracking the error I identified Spring was looking inside my DTO a property named $gte
(it will also look for $ge
, $lt
, $lte
). After adding field for these properties and created its getter and setter methods my aggregation query operation is working.
I don't know if there is something wrong with my implementation of Spring Data for MongoDB or there is something wrong in version 1.8.0 of the API, but so far this has been the best possible solution.
Upvotes: 0