Interface ReservationRepository

All Superinterfaces:
org.springframework.data.repository.CrudRepository<Reservation, Long>, org.springframework.data.jpa.repository.JpaRepository<Reservation, Long>, org.springframework.data.repository.ListCrudRepository<Reservation, Long>, org.springframework.data.repository.ListPagingAndSortingRepository<Reservation, Long>, org.springframework.data.repository.PagingAndSortingRepository<Reservation, Long>, org.springframework.data.repository.query.QueryByExampleExecutor<Reservation>, org.springframework.data.repository.Repository<Reservation, Long>

@Table(name="reservations") public interface ReservationRepository extends org.springframework.data.jpa.repository.JpaRepository<Reservation, Long>
Fetches/saves Reservations from/to the database table reservations.
  • Method Details

    • findAll

      @NonNull @NonNull org.springframework.data.domain.Page<Reservation> findAll(@NonNull @NonNull org.springframework.data.domain.Pageable pageable)
      A subset of all Reservations in the database table according to the given Pageable.
      Specified by:
      findAll in interface org.springframework.data.repository.PagingAndSortingRepository<Reservation, Long>
      Parameters:
      pageable - The pagination information specifying which page of Reservations shall be returned.
      Returns:
      All Reservations, but only the specified subset.
    • findReservationsByRoomId

      @NonNull @NonNull LinkedHashSet<Reservation> findReservationsByRoomId(@NonNull @Param("roomId") @NonNull Long roomId)
      Fetches all Reservations from the database placed for the Room with the given Room.id.
      Parameters:
      roomId - The ID of the Room whose Reservations shall be looked for.
      Returns:
      All Reservations for the specified Room.
    • findReservationsByApplicant

      @NonNull @NonNull LinkedHashSet<Reservation> findReservationsByApplicant(@NonNull @NonNull Actor applicant)
      Fetches all Reservations from the database placed by the given Actor.
      Parameters:
      applicant - The user whose Reservations shall be looked for.
      Returns:
      All Reservations of the specified user.
    • findCurrentReservationsByApplicant

      @Query("select r from Reservation r where r.endDate > :now") @NonNull @NonNull org.springframework.data.domain.Page<Reservation> findCurrentReservationsByApplicant(@NonNull @NonNull Actor applicant, @NonNull @NonNull LocalDateTime now, @NonNull @NonNull org.springframework.data.domain.Pageable pageable)
      Fetches all Reservations from the database placed by the given Actor where the Reservation.endDate is in the future.
      Parameters:
      applicant - The user whose Reservations shall be looked for.
      now - The current time.
      pageable - The pagination information specifying which page of Reservations shall be returned.
      Returns:
      All Reservations of the specified user.
    • findReservationsByApplicantUserName

      @NonNull @NonNull org.springframework.data.domain.Page<Reservation> findReservationsByApplicantUserName(@NonNull @NonNull String userName, @NonNull @NonNull org.springframework.data.domain.Pageable pageable)
      Fetches all Reservations from the database placed by the Actor with the given Actor.userName.
      Parameters:
      userName - The user whose Reservations shall be looked for.
      pageable - The pagination information specifying which page of Reservations shall be returned.
      Returns:
      All Reservations of the specified user.
    • findReservationByRoomForDate

      @Query("select r from Reservation r where r.room.id = :roomId and r.startDate < :date and r.endDate > :date") @NonNull @NonNull Optional<Reservation> findReservationByRoomForDate(@NonNull @Param("roomId") @NonNull Long roomId, @NonNull @Param("date") @NonNull LocalDateTime date)
      Fetches the Reservation – for the given Room – that starts before and ends after the given LocalDateTime from the database. (There can only be one Reservation at a time for each Room.)
      Parameters:
      roomId - The Room.id of the Room that shall match the Reservation looked for.
      date - The point in time at which the Reservation looked for takes place.
      Returns:
      The Reservation that matches the given Room and date. Empty if there is no such Reservation.
    • findReservationsBetweenDates

      @Query("select r from Reservation r where (r.startDate between :startDate and :endDate) or (r.endDate between :startDate and :endDate) or (r.startDate < :startDate and r.endDate > :endDate)") @NonNull @NonNull Set<Reservation> findReservationsBetweenDates(@NonNull @Param("startDate") @NonNull LocalDateTime startDate, @NonNull @Param("endDate") @NonNull LocalDateTime endDate)

      Fetches all Reservations from the database that

      • start or end between the two given dates or
      • start before and end after the given period.
      Parameters:
      startDate - The Reservations looked for start or end after this date.
      endDate - The Reservations looked for start or end before this date.
      Returns:
      All Reservations between the two dates.
    • findReservationsBetweenDatesForRoom

      @Query("select r from Reservation r where r.room.id = :roomId and ((r.startDate between :startDate and :endDate) or (r.endDate between :startDate and :endDate) or (r.startDate < :startDate and r.endDate > :endDate)) order by r.startDate asc") @NonNull @NonNull LinkedHashSet<Reservation> findReservationsBetweenDatesForRoom(@NonNull @Param("roomId") @NonNull Long roomId, @NonNull @Param("startDate") @NonNull LocalDateTime startDate, @NonNull @Param("endDate") @NonNull LocalDateTime endDate)

      Fetches all Reservations from the database placed for the Room with the given Room.id and

      • starting or ending between the two given dates or
      • starting before the given start-date and ending after the given end-date.

      To be clear: Only those Reservations are returned that simultaneously match the Room ID and the specified date interval.

      Parameters:
      roomId - The ID of the Room whose Reservations shall be looked for.
      startDate - The Reservations looked for start or end after this date.
      endDate - The Reservations looked for start or end before this date.
      Returns:
      The Reservations between the two dates for the given Room. Will be sorted by the Reservation.startDate, ascending.
    • findSeatReservationsBetweenDatesForRoom

      @Query("select r from SeatReservation r where r.room.id = :roomId and ((r.startDate between :startDate and :endDate) or (r.endDate between :startDate and :endDate) or (r.startDate < :startDate and r.endDate > :endDate)) order by r.startDate asc") @NonNull @NonNull LinkedHashSet<SeatReservation> findSeatReservationsBetweenDatesForRoom(@NonNull @Param("roomId") @NonNull Long roomId, @NonNull @Param("startDate") @NonNull LocalDateTime startDate, @NonNull @Param("endDate") @NonNull LocalDateTime endDate)

      Fetches all SeatReservations from the database placed for the Room with the given Room.id and

      • starting or ending between the two given dates or
      • starting before the given start-date and ending after the given end-date.

      To be clear: Only those SeatReservation are returned that simultaneously match the Room ID and the specified date interval.

      Parameters:
      roomId - The ID of the Room whose SeatReservations shall be looked for.
      startDate - The SeatReservations looked for start or end after this date.
      endDate - The SeatReservations looked for start or end before this date.
      Returns:
      The SeatReservations between the two dates for the given Room. Will be sorted by the Reservation.startDate, ascending.
    • findReservationsBetweenDatesForApplicant

      @Query("select r from Reservation r where r.applicant.id = :applicantId and ((r.startDate between :startDate and :endDate) or (r.endDate between :startDate and :endDate) or (r.startDate < :startDate and r.endDate > :endDate))") @NonNull @NonNull Set<Reservation> findReservationsBetweenDatesForApplicant(@NonNull @Param("applicantId") @NonNull Long applicantId, @NonNull @Param("startDate") @NonNull LocalDateTime startDate, @NonNull @Param("endDate") @NonNull LocalDateTime endDate)

      Fetches all Reservations from the database placed for the Reservation.applicant with the given Actor.id and

      • starting or ending between the two given dates or
      • starting before and ending after the given dates.

      To be clear: Only those Reservations are returned that simultaneously match the Actor ID and the specified date interval.

      Parameters:
      applicantId - The ID of the applicant whose Reservations shall be looked for.
      startDate - The Reservations looked for start or end after this date.
      endDate - The Reservations looked for start or end before this date.
      Returns:
      The Reservations between the two dates for the given applicant.
    • findReservationsAfterDateForApplicant

      @Query("select r from Reservation r where r.applicant.id = :applicantId and (r.startDate > :date or r.endDate > :date)") @NonNull @NonNull LinkedHashSet<Reservation> findReservationsAfterDateForApplicant(@NonNull @Param("applicantId") @NonNull Long applicantId, @NonNull @Param("date") @NonNull LocalDateTime date)

      Fetches all Reservations from the database placed for the Reservation.applicant with the given Actor.id and starting or ending after the given date.

      To be clear: Only those Reservations are returned that simultaneously match the Actor ID and the specified lower (exclusive) date-boundary.

      Parameters:
      applicantId - The ID of the applicant whose Reservations shall be looked for.
      date - The Reservations looked for start or end after this date (greater than).
      Returns:
      The Reservations between the two dates for the given applicant.
    • existsById

      boolean existsById(@NonNull @NonNull Long id)
      Specified by:
      existsById in interface org.springframework.data.repository.CrudRepository<Reservation, Long>
    • existsByApplicantAndId

      boolean existsByApplicantAndId(@NonNull @NonNull Actor applicant, @NonNull @NonNull Long id)
      Checks whether the given Actor has a Reservation with the given Reservation.id.
      Parameters:
      applicant - The Actor whose Reservation is looked for.
      id - The identifier of the Reservation looked for.
      Returns:
      True if the Actor has a Reservation with the ID, false otherwise.
    • deleteById

      void deleteById(@NonNull @NonNull Long id)
      Specified by:
      deleteById in interface org.springframework.data.repository.CrudRepository<Reservation, Long>
    • deleteAllById

      void deleteAllById(@NonNull @NonNull Iterable<@NonNull ? extends Long> ids)
      Specified by:
      deleteAllById in interface org.springframework.data.repository.CrudRepository<Reservation, Long>