package org.example.seed.repository;

import org.example.seed.entity.ChefEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.Optional;

/**
 * Created by PINA on 25/06/2017.
 */
@Repository
public interface ChefRepository extends JpaRepository<ChefEntity, String> {

  Optional<ChefEntity> findById(final String id);

  @Query("SELECT ce FROM ChefEntity ce LEFT JOIN ce.account AS ae JOIN ce.dishes AS se WHERE ce.active = TRUE AND se.id = ?1")
  ChefEntity findOneByDish(final String idDish);
}

@@ -27,24 +27,68 @@
 epository;%0A%0A
+import org.example.seed.catalog.ChefStatus;%0A
 import org.e
@@ -495,16 +495,262 @@
 g id);%0A%0A
+  Optional%3CChefEntity%3E findByIdAndStatus(final String id, final ChefStatus status);%0A%0A  @Query(%22SELECT CASE WHEN COUNT(ce) %3E 0 THEN true ELSE false END FROM ChefEntity ce WHERE ce.account.email = ?1%22)%0A  boolean existsByEmail(final String email);%0A%0A
   @Query

add existByEmail method