org.springframework.data.mongodb.core.MongoTemplate.findAll()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(211)

本文整理了Java中org.springframework.data.mongodb.core.MongoTemplate.findAll()方法的一些代码示例,展示了MongoTemplate.findAll()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MongoTemplate.findAll()方法的具体详情如下:
包路径:org.springframework.data.mongodb.core.MongoTemplate
类名称:MongoTemplate
方法名:findAll

MongoTemplate.findAll介绍

暂无

代码示例

代码示例来源:origin: yu199195/hmily

@Override
public List<HmilyTransaction> listAll() {
  final List<MongoAdapter> resultList = template.findAll(MongoAdapter.class, collectionName);
  if (CollectionUtils.isNotEmpty(resultList)) {
    return resultList.stream().map(this::buildByCache).collect(Collectors.toList());
  }
  return Collections.emptyList();
}

代码示例来源:origin: spring-projects/spring-data-mongodb

@Override
public <T> List<T> findAll(Class<T> entityClass) {
  return findAll(entityClass, operations.determineCollectionName(entityClass));
}

代码示例来源:origin: kaaproject/kaa

public List<T> find() {
 LOG.debug("Find  all documents from [{}] collection.", getCollectionName());
 return mongoTemplate.findAll(getDocumentClass());
}

代码示例来源:origin: org.springframework.data/spring-data-mongodb

@Override
public <T> List<T> findAll(Class<T> entityClass) {
  return findAll(entityClass, operations.determineCollectionName(entityClass));
}

代码示例来源:origin: javahongxi/whatsmars

@Override
public void run(String... args) throws Exception {
  this.repository.deleteAll();
  // save a couple of customers
  this.repository.save(new Customer("Alice", "Smith"));
  this.repository.save(new Customer("Bob", "Smith"));
  // fetch all customers
  System.out.println("Customers found with findAll():");
  System.out.println("-------------------------------");
  for (Customer customer : this.repository.findAll()) {
    System.out.println(customer);
  }
  System.out.println();
  // fetch an individual customer
  System.out.println("Customer found with findByFirstName('Alice'):");
  System.out.println("--------------------------------");
  System.out.println(this.repository.findByFirstName("Alice"));
  System.out.println("Customers found with findByLastName('Smith'):");
  System.out.println("--------------------------------");
  for (Customer customer : this.repository.findByLastName("Smith")) {
    System.out.println(customer);
  }
  System.out.println("--------------------------------");
  System.out.println("mongoTemplate operations...");
  for (Customer customer : mongoTemplate.findAll(Customer.class)) {
    System.out.println(customer);
  }
}

代码示例来源:origin: com.sangupta/jerry

/**
 * 
 */
@Override
public List<T> getAllEntities() {
  return this.mongoTemplate.findAll(this.entityClass);
}

代码示例来源:origin: rstyro/Springboot

/**
 * 查询所有
 */
@Override
public List<User> findAll() {
  return mongoTemplate.findAll(User.class);
}

代码示例来源:origin: com.sangupta/jerry-services

@Override
public List<T> getAllEntities() {
  return this.mongoTemplate.findAll(this.entityClass);
}

代码示例来源:origin: enilu/springboot-elm

public List findAll(String collection) {
  return mongoTemplate.findAll(Map.class, collection);
}
public List<Map> findAll(String collectionName,Object... keyValues){

代码示例来源:origin: at.researchstudio.sat/won-bot

@Override
public List<URI> getNamedNeedUriList(final String name) {
  return template.findAll(URI.class, name);
}

代码示例来源:origin: com.sangupta/jerry-services

@Override
public List<Configuration> getAllConfigurations() {
  return this.mongoTemplate.findAll(Configuration.class);
}

代码示例来源:origin: Apress/beg-spring-boot-2

public List<User> getUsers()
{
  return mongoTemplate.findAll(User.class, "users");
}

代码示例来源:origin: fernandospr/spring-jetty-example

@Override
public List<Student> findAll() {
  return this.mongoTemplate.findAll(Student.class);
}

代码示例来源:origin: enilu/springboot-elm

public <T> List<T> findAll(Class<T> klass) {
  return mongoTemplate.findAll(klass);
}
public <T> List<T> findAll(Class<T> klass,Object... keyValues) {

代码示例来源:origin: at.researchstudio.sat/won-bot

@Override
public Set<URI> retrieveAllNeedUris() {
  Set<URI> uris = new HashSet<>();
  List<MongoContextObjectList> contextObjects = template.findAll(MongoContextObjectList.class, NEED_URI_COLLECTION);
  for (MongoContextObjectList mco : contextObjects) {
    List<Object> objectList = mco.getList();
    if (objectList != null) {
      Set<URI> tempSet = mco.getList().stream().map(x -> (URI) x).collect(Collectors.toSet());
      uris.addAll(tempSet);
    }
  }
  return uris;
}

代码示例来源:origin: at.researchstudio.sat/won-bot

@Override
public Map<String, List<Object>> loadListMap(final String collectionName) {
  checkValidCollectionName(collectionName);
  List<MongoContextObjectList> contextObjects = template.findAll(MongoContextObjectList.class, collectionName);
  HashMap<String, List<Object>> objectMap = new HashMap<>();
  for (MongoContextObjectList mco : contextObjects) {
    objectMap.put(mco.getId(), mco.getList());
  }
  return objectMap;
}

代码示例来源:origin: at.researchstudio.sat/won-bot

@Override
public Map<String, Object> loadObjectMap(String collectionName) {
  checkValidCollectionName(collectionName);
  List<MongoContextObject> contextObjects = template.findAll(MongoContextObject.class, collectionName);
  HashMap<String, Object> objectMap = new HashMap<>();
  for (MongoContextObject mco : contextObjects) {
    objectMap.put(mco.getId(), mco.getObject());
  }
  return objectMap;
}

代码示例来源:origin: enilu/springboot-elm

public Map findOne(String collectionName, Object... extraKeyValues) {
  Criteria criteria = criteria(extraKeyValues);
  if (criteria == null) {
    List<Map> list = mongoTemplate.findAll(Map.class, collectionName);
    if (list != null) {
      return list.get(0);
    }
    return null;
  }
  return mongoTemplate.findOne(Query.query(criteria), Map.class, collectionName);
}

代码示例来源:origin: enilu/springboot-elm

public <T> T findOne(Class<T> klass, Object... keyValues) {
  Criteria criteria = criteria(keyValues);
  if (criteria == null) {
    List<T> list = mongoTemplate.findAll(klass);
    if (list != null) {
      return list.get(0);
    }
    return null;
  }
  return mongoTemplate.findOne(Query.query(criteria), klass);
}

代码示例来源:origin: stackoverflow.com

System.out.println(mongoTemplate.findAll(Customer.class));;

相关文章