List of usage examples for org.springframework.data.mongodb.core MongoOperations getCollection
MongoCollection<Document> getCollection(String collectionName);
From source file:uk.ac.ebi.eva.pipeline.jobs.steps.IndexesGeneratorStep.java
@Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { ObjectMap pipelineOptions = jobOptions.getPipelineOptions(); MongoOperations operations = MongoDBHelper.getMongoOperationsFromPipelineOptions(pipelineOptions); operations.getCollection(pipelineOptions.getString("db.collections.features.name")).createIndex( new BasicDBObject("name", 1), new BasicDBObject("sparse", true).append("background", true)); return RepeatStatus.FINISHED; }
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();/* w ww. j a v a2 s. c om*/ //System.out.println(tobj.get("_id")); } List<Marker> listUser = mongoOperation.findAll(Marker.class, "markers"); return listUser; }