sql -> hql

This commit is contained in:
Filip Izydorczyk 2020-09-02 16:56:49 +02:00
parent 5b0da1c280
commit bf5b78c3b6
3 changed files with 4 additions and 4 deletions

View File

@ -9,6 +9,6 @@ import org.springframework.stereotype.Repository;
@Repository
public interface CourseRepository extends JpaRepository<Course, Long> {
@Query(value = "SELECT * FROM course WHERE name = :name", nativeQuery = true)
@Query("FROM Course WHERE name = ?1")
Course findByName(@Param("name") String name);
}

View File

@ -11,10 +11,10 @@ import org.springframework.stereotype.Repository;
@Repository
public interface GroupRepository extends JpaRepository<Groups, Long> {
@Query(value = "SELECT * FROM groups WHERE time = :time AND room = :room AND capacity = :capacity ", nativeQuery = true)
@Query("FROM Groups WHERE time = ?1 AND room = ?2 AND capacity = ?3")
Groups find(@Param("time") int time, @Param("room") String room, @Param("capacity") int capacity);
@Query(value = "SELECT * FROM groups WHERE course_id = :id", nativeQuery = true)
@Query("FROM Groups WHERE course_id = ?1")
List<Groups> getByCourse(@Param("id") Long id);
}

View File

@ -9,6 +9,6 @@ import org.springframework.stereotype.Repository;
@Repository
public interface LecturerRepository extends JpaRepository<Lecturer, Long> {
@Query(value = "SELECT * FROM lecturer WHERE name = :name AND surname = :surname AND title = :title ", nativeQuery = true)
@Query("FROM Lecturer WHERE title = ?1 AND name = ?2 AND surname = ?3")
Lecturer find(@Param("title") String title, @Param("name") String name, @Param("surname") String surname);
}