Подтвердить что ты не робот

Spring -data findFirstBy throws IncorrectResultSizeDataAccessException?

Я хочу использовать sql select по имени метода в spring -data.

Выбор следует заказывать по цене.

@Entity
public class Product {
    int name;
    BigDecimal price;
}

interface ProductRepository extends CrudRepository<Product, Long> {
    Product findFirstByNameOrderByPriceAsc(String name);
}

Результат:

org.springframework.dao.IncorrectResultSizeDataAccessException: result returns more than one elements; nested exception is javax.persistence.NonUniqueResultException: result returns more than one elements

Почему? Я точно использовал метод findFirst() по этой причине, чтобы получить лучший результат, если найдено более одного.

4b9b3361