source: src/main/java/com/example/villadihovo/repository/reservation/GuestMakeReservationRepository.java

Last change on this file was f7c05a1, checked in by Elena Shulevska <elena.shulevska@…>, 15 months ago

initial commit of the source code on origin

  • Property mode set to 100644
File size: 2.0 KB
Line 
1package com.example.villadihovo.repository.reservation;
2
3import com.example.villadihovo.dto.ReservationForRoomDto;
4import com.example.villadihovo.model.reservations.GuestMakeReservationId;
5import com.example.villadihovo.model.reservations.GuestsMakeReservation;
6import org.springframework.data.jpa.repository.JpaRepository;
7import org.springframework.data.jpa.repository.Query;
8import org.springframework.data.repository.query.Param;
9import org.springframework.stereotype.Repository;
10
11import java.util.List;
12
13@Repository
14public interface GuestMakeReservationRepository extends JpaRepository<GuestsMakeReservation, GuestMakeReservationId> {
15 @Query("SELECT new com.example.villadihovo.dto.ReservationForRoomDto(gmr.reservation_id, r2.room_id, r.start_date , r.end_date, r.number_guests,r.adults,r.children,r2.room_type, r2.price, v.name ,ut.full_name, ut.phone_number)" +
16 " FROM GuestsMakeReservation gmr " +
17 "JOIN UserTable ut ON gmr.user_id = ut.user_id " +
18 "JOIN Reservation r ON gmr.reservation_id = r.reservation_id " +
19 "JOIN Rooms r2 ON r.room_id.room_id = r2.room_id " +
20 "JOIN Villa v ON r.villa_id.villa_id = v.villa_id " +
21 "ORDER BY r.start_date")
22 List<ReservationForRoomDto> findAllRoomReservationsDTO();
23
24 @Query("SELECT new com.example.villadihovo.dto.ReservationForRoomDto(gmr.reservation_id, r2.room_id, r.start_date , r.end_date, r.number_guests,r.adults,r.children,r2.room_type, r2.price, v.name ,ut.full_name, ut.phone_number)" +
25 " FROM GuestsMakeReservation gmr " +
26 "JOIN UserTable ut ON gmr.user_id = ut.user_id " +
27 "JOIN Reservation r ON gmr.reservation_id = r.reservation_id " +
28 "JOIN Rooms r2 ON r.room_id.room_id = r2.room_id " +
29 "JOIN Villa v ON r.villa_id.villa_id = v.villa_id " +
30 "WHERE r.reservation_id = gmr.reservation_id AND r.reservation_id = :id")
31 ReservationForRoomDto findRoomReservationsDTOById(@Param("id") Integer id);
32}
Note: See TracBrowser for help on using the repository browser.