package net.safedata.springboot.training.d02.s05.repository;

import net.safedata.springboot.training.d02.s05.model.Product;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * A simple Spring Data {@link CrudRepository} for the {@link Product} entity
 *
 * @author bogdan.solga
 */
@Repository
@SuppressWarnings("unused")
public interface ProductRepository extends CrudRepository<Product, Integer> {

    List<Product> findByName(final String name);

    @Query(value =  "SELECT product " +
                    "FROM Product product " +
                    "WHERE product.name LIKE :name"
    )
    List<Product> findProductsWhichIncludeName(final @Param(value = "name") String name);
}

@@ -360,16 +360,43 @@
 il.List;
+%0Aimport java.util.Optional;
 %0A%0A/**%0A *
@@ -621,24 +621,33 @@
 ger%3E %7B%0A%0A    
+Optional%3C
 List%3CProduct
@@ -643,24 +643,25 @@
 ist%3CProduct%3E
+%3E
  findByName(
@@ -829,16 +829,25 @@
   )%0A    
+Optional%3C
 List%3CPro
@@ -851,16 +851,17 @@
 Product%3E
+%3E
  findPro
@@ -882,22 +882,16 @@
 udeName(
-final 
 @Param(v
@@ -904,16 +904,22 @@
  %22name%22)
+ final
  String 
@@ -924,11 +924,52 @@
 g name);
+%0A%0A    Optional%3CProduct%3E findById(int id);
 %0A%7D%0A

Use Optional return values for all the queries