@Override public Set<String> getScriptNames() { List<NamedMongoScript> scripts = mongoOperations.findAll(NamedMongoScript.class, SCRIPT_COLLECTION_NAME); if (CollectionUtils.isEmpty(scripts)) { return Collections.emptySet(); } Set<String> scriptNames = new HashSet<String>(); for (NamedMongoScript script : scripts) { scriptNames.add(script.getName()); } return scriptNames; }
@Override public Set<String> getScriptNames() { List<NamedMongoScript> scripts = mongoOperations.findAll(NamedMongoScript.class, SCRIPT_COLLECTION_NAME); if (CollectionUtils.isEmpty(scripts)) { return Collections.emptySet(); } Set<String> scriptNames = new HashSet<String>(); for (NamedMongoScript script : scripts) { scriptNames.add(script.getName()); } return scriptNames; }
@Override public List<Trace> findAll() { return mongoOps.findAll(Trace.class); }
MongoOperations mongoOperations = mongoConfiguration.getMongoTemplate(); List<Resource> resourceList = mongoOperations.findAll(Resource.class).sort({'_id' : 1}); return resourceList;
@Override @Transactional(readOnly = true) public List<RegisteredService> load() { return this.mongoTemplate.findAll(RegisteredService.class, this.collectionName); }
@Override @Cacheable(cacheResolver="secondaryCacheResolver" ,unless="#result == null") public List<T> getAll() throws DataAccessException { if (logger.isDebugEnabled()) logger.debug("type {} getAll", type); try { return mongoOperations.findAll(type); } catch (Exception e) { throw new DataAccessException(e); } }
public void run() { if (mongoOperations.collectionExists(Person.class)) { mongoOperations.dropCollection(Person.class); } mongoOperations.createCollection(Person.class); Person p = new Person("John", 39); Account a = new Account("1234-59873-893-1", Account.Type.SAVINGS, 123.45D); p.getAccounts().add(a); mongoOperations.insert(p); List<Person> results = mongoOperations.findAll(Person.class); System.out.println("Results: " + results); }
@Test public void testSave_DoMappingUsingDozerAndThenSavesDocumentIntoMongodb() { inventoryMongoRepository.save(new Inventory("Apple Watch", 20.0)); List<InventoryDocument> allInventory = mongoOperations.findAll(InventoryDocument.class); assertThat(allInventory).hasSize(1); assertThat(allInventory.get(0).getId()).isNotNull(); assertThat(allInventory.get(0)) .isEqualToIgnoringGivenFields(new InventoryDocument("Apple Watch", 20.0), "id"); }