Description
Cesar Tron-Lozai opened DATAMONGO-2177 and commented
When migrating to 2.1.3 I noticed that the asDBobject
method of SpringDataMongodbQuery method has been removed
I tried to work around it by trying to extend the class but most of the useful methods are either private or package private which makes it really hard to do that sort of things.
The reason I need that is because I want to to use a QueryDsl predicate into an aggregation pipeline.
I used to do it with something like that:
final SpringDataMongodbQuery<Foo> query = new SpringDataMongodbQuery<>(template, Opportunity.class).where(predicate);
final BasicDBObject dbObject = (BasicDBObject) query.asDBObject();
Then I would do some modification on the DBObject to add a prefix required by the aggregation and finally transform it into a CriteriaDefinition:
private CriteriaDefinition fromDocument(Document dbObject) {
return new CriteriaDefinition() {
@Override
public Document getCriteriaObject() {
return dbObject;
}
@Override
public String getKey() {
return null;
}
};
}
Now that the asDBObject method is method is gone, how can I get a Document or DBobject from a Predicate or a query?
Issue Links:
- DATAMONGO-2233 Convert Querydsl Predicate to org.bson.Document
("is duplicated by")
1 votes, 3 watchers