use of dev.morphia.query.internal.MorphiaCursor in project morphia by mongodb.
the class AggregationImpl method execute.
@Override
public <R> MorphiaCursor<R> execute(Class<R> resultType) {
MongoCursor<R> cursor;
if (datastore.getMapper().isMappable(resultType) && !resultType.equals(this.collection.getDocumentClass())) {
MongoCollection<Document> collection = this.collection.withDocumentClass(Document.class);
MongoCursor<Document> results = collection.aggregate(getDocuments()).iterator();
EntityModel entityModel = datastore.getMapper().getEntityModel(this.collection.getDocumentClass());
cursor = new MappingCursor<>(results, datastore.getCodecRegistry().get(resultType), entityModel.getDiscriminatorKey());
} else {
cursor = collection.aggregate(getDocuments(), resultType).iterator();
}
return new MorphiaCursor<>(cursor);
}
use of dev.morphia.query.internal.MorphiaCursor in project morphia by MorphiaOrg.
the class AggregationImpl method execute.
@Override
public <R> MorphiaCursor<R> execute(Class<R> resultType) {
MongoCursor<R> cursor;
if (datastore.getMapper().isMappable(resultType) && !resultType.equals(this.collection.getDocumentClass())) {
MongoCollection<Document> collection = this.collection.withDocumentClass(Document.class);
MongoCursor<Document> results = collection.aggregate(getDocuments()).iterator();
EntityModel entityModel = datastore.getMapper().getEntityModel(this.collection.getDocumentClass());
cursor = new MappingCursor<>(results, datastore.getCodecRegistry().get(resultType), entityModel.getDiscriminatorKey());
} else {
cursor = collection.aggregate(getDocuments(), resultType).iterator();
}
return new MorphiaCursor<>(cursor);
}
Aggregations