Example usage for org.springframework.data.jpa.repository JpaRepository getOne

List of usage examples for org.springframework.data.jpa.repository JpaRepository getOne

Introduction

In this page you can find the example usage for org.springframework.data.jpa.repository JpaRepository getOne.

Prototype

T getOne(ID id);

Source Link

Document

Returns a reference to the entity with the given identifier.

Usage

From source file:com.nestedbird.modules.formparser.FormParse.java

/**
 * Parses a comma separated value of database indexes.
 * Retrieves all the items from the database and adds them to an array to save them to the object
 *
 * @param value           CSV of indexes
 * @param repositoryClass repository of entities
 * @return array of entities/*  www.j a  v  a  2s .  c o  m*/
 */
private Collection<BaseEntity> parseCSVDatabaseIndexes(final String value, final Class repositoryClass) {
    final Set<BaseEntity> elements = new HashSet<>();
    final JpaRepository repository = getFieldRepository(repositoryClass);
    Arrays.stream(value.split(",")).distinct().filter(Objects::nonNull).filter(UUIDConverter::isUUID)
            .forEach(id -> elements.add((BaseEntity) repository.getOne(id)));
    return elements;
}