Skip to content

Commit

Permalink
Cria projection para ingrediente
Browse files Browse the repository at this point in the history
  • Loading branch information
julianocanuto committed Dec 30, 2021
1 parent 06caeb1 commit 6e14d7f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
package com.julianocanuto.controleestoque.repositorios;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.julianocanuto.controleestoque.entidades.Ingrediente;
import com.julianocanuto.controleestoque.repositorios.projections.IngredienteNomeQuantidadeProjection;

@Repository
public interface IngredienteRepository extends JpaRepository<Ingrediente, Long>{

@Query(nativeQuery = true,
value = "SELECT TB_INGREDIENTE.nome, TB_ESTOQUE.quantidade "
+ "FROM TB_INGREDIENTE "
+ "INNER JOIN TB_ESTOQUE ON TB_INGREDIENTE.estoque_id = TB_ESTOQUE.id")
List<IngredienteNomeQuantidadeProjection> getNomeQuantidadeIngredientes();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.julianocanuto.controleestoque.repositorios.projections;

public interface IngredienteNomeQuantidadeProjection {

String getNome();
Integer getQuantidade();
}

0 comments on commit 6e14d7f

Please sign in to comment.