VariableRepository.java 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. package fr.triplea.demovote.dao;
  2. import java.util.List;
  3. import org.springframework.data.jpa.repository.JpaRepository;
  4. import org.springframework.data.jpa.repository.NativeQuery;
  5. import org.springframework.data.repository.query.Param;
  6. import fr.triplea.demovote.dto.VariableTypeOptionList;
  7. import fr.triplea.demovote.model.Variable;
  8. public interface VariableRepository extends JpaRepository<Variable, Integer>
  9. {
  10. @NativeQuery("SELECT DISTINCT v.* FROM vote.variables AS v ORDER BY v.type ASC, v.code ASC ")
  11. List<Variable> findAll();
  12. @NativeQuery("SELECT DISTINCT v.* FROM vote.variables AS v WHERE v.numero_variable = :id ")
  13. Variable findById(@Param("id") int id);
  14. @NativeQuery("SELECT DISTINCT v.* FROM vote.variables AS v WHERE v.type = :type ORDER BY v.type ASC, v.code ASC ")
  15. List<Variable> findByType(@Param("type") String type);
  16. @NativeQuery("SELECT DISTINCT v.valeur FROM vote.variables AS v WHERE v.type = :type AND v.code = :code ")
  17. String findByTypeAndCode(@Param("type") String type, @Param("code") String code);
  18. @NativeQuery("SELECT DISTINCT v.type FROM vote.variables AS v ORDER BY v.type ASC ")
  19. List<VariableTypeOptionList> getTypes();
  20. }