Example usage for org.springframework.data.repository CrudRepository findAll

List of usage examples for org.springframework.data.repository CrudRepository findAll

Introduction

In this page you can find the example usage for org.springframework.data.repository CrudRepository findAll.

Prototype

Iterable<T> findAll();

Source Link

Document

Returns all instances of the type.

Usage

From source file:com.redhat.rhtracking.persistance.services.Queries.java

public static <T extends Catalog, K extends Serializable> void initCatalog(List<String> catalogue,
        CrudRepository<T, K> repository, Class<T> type) {
    logger.info("Starting " + type.getSimpleName() + " catalog");
    Iterable<T> typeItr = repository.findAll();
    for (T t : typeItr) {
        if (catalogue.contains(t.toString())) {
            catalogue.remove(t.toString());
        }/*from  ww w.j a  v  a 2  s.c  o m*/
    }
    if (!catalogue.isEmpty()) {
        try {
            for (String s : catalogue) {
                T missing = type.newInstance();
                missing.setType(s);
                repository.save(missing);
            }
        } catch (IllegalAccessException | InstantiationException ex) {
            logger.error(ex);
        }
    }
}

From source file:org.openlmis.fulfillment.AuditLogInitializer.java

private void createSnapshots(CrudRepository<?, ?> repository) {
    //... retrieve all of its domain objects and...
    repository.findAll().forEach(this::createSnapshot);
}