Changeset 9bf1f8d for springapp/src/main/java/mk/profesori/springapp/Repository/FacultyRepository.java
- Timestamp:
- 01/20/23 22:57:18 (17 months ago)
- Branches:
- main
- Children:
- 8dffe02
- Parents:
- 4abf55a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
springapp/src/main/java/mk/profesori/springapp/Repository/FacultyRepository.java
r4abf55a r9bf1f8d 1 1 package mk.profesori.springapp.Repository; 2 3 import mk.profesori.springapp.Model.Faculty; 4 import mk.profesori.springapp.Model.University; 5 import org.springframework.data.jpa.repository.Query; 6 import org.springframework.data.repository.CrudRepository; 7 import org.springframework.data.repository.query.Param; 8 import org.springframework.stereotype.Repository; 2 9 3 10 import java.util.List; 4 11 5 import org.springframework.data.repository.CrudRepository;6 import org.springframework.stereotype.Repository;7 8 import mk.profesori.springapp.Model.Faculty;9 import mk.profesori.springapp.Model.University;10 11 12 @Repository 12 13 public interface FacultyRepository extends CrudRepository<Faculty, Long>{ 13 14 14 List<Faculty> findAll(); 15 15 Faculty findByFacultyId(Long id); 16 16 List<Faculty> findByUniversity(University university); 17 @Query(value = "select professor.id, count(p.*)\n" + 18 "from professor left join post p on professor.id = p.professor_id\n" + 19 "where professor.faculty_id = :facultyId\n" + 20 "group by professor.id\n" + 21 "order by professor.id;", nativeQuery = true) 22 List<String> getOpinionCountForEachProfessorInFaculty(@Param("facultyId") Long id); 17 23 }
Note:
See TracChangeset
for help on using the changeset viewer.