main
Last change
on this file was deea3c4, checked in by Aleksandar Panovski <apano77@…>, 6 weeks ago |
Big change done fully handle_reservation_update() trigger works
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | package com.example.rezevirajmasa.demo.repository;
|
---|
2 |
|
---|
3 | import com.example.rezevirajmasa.demo.model.Restaurant;
|
---|
4 | import com.example.rezevirajmasa.demo.model.TableEntity;
|
---|
5 | import org.springframework.data.jpa.repository.JpaRepository;
|
---|
6 | import org.springframework.data.jpa.repository.Query;
|
---|
7 | import org.springframework.data.repository.query.Param;
|
---|
8 |
|
---|
9 | import java.time.LocalDateTime;
|
---|
10 | import java.util.List;
|
---|
11 |
|
---|
12 | public interface TableRepository extends JpaRepository<TableEntity, Long> {
|
---|
13 | List<TableEntity> findByRestaurant(Restaurant restaurant);
|
---|
14 | List<TableEntity> findAllByCapacityGreaterThanEqual(int capacity);
|
---|
15 | @Query("SELECT t FROM TableEntity t WHERE t.capacity >= :capacity AND NOT EXISTS (" +
|
---|
16 | "SELECT r FROM t.reservations r WHERE r.checkInTime <= :checkOutTime AND r.checkOutTime >= :checkInTime)")
|
---|
17 | List<TableEntity> findAvailableTables(@Param("checkInTime") LocalDateTime checkInTime,
|
---|
18 | @Param("checkOutTime") LocalDateTime checkOutTime,
|
---|
19 | @Param("capacity") int capacity);
|
---|
20 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.