Example usage for org.springframework.data.mongodb.core MongoOperations findAll

List of usage examples for org.springframework.data.mongodb.core MongoOperations findAll

Introduction

In this page you can find the example usage for org.springframework.data.mongodb.core MongoOperations findAll.

Prototype

<T> List<T> findAll(Class<T> entityClass, String collectionName);

Source Link

Document

Query for a list of objects of type T from the specified collection.

Usage

From source file:com.mycompany.model.MongoDBTest.java

public List<Marker> getMarker() {
    ApplicationContext ctx = new AnnotationConfigApplicationContext(MongoConfig.class);
    MongoOperations mongoOperation = (MongoOperations) ctx.getBean("mongoTemplate");

    DBCollection markerCollection = mongoOperation.getCollection("markers");
    DBCursor result = markerCollection.find();

    while (result.hasNext()) {
        DBObject tobj = result.next();//from   w  w  w.  j a va  2  s.  c o m
        //System.out.println(tobj.get("_id"));

    }

    List<Marker> listUser = mongoOperation.findAll(Marker.class, "markers");

    return listUser;

}