Package app.YUP.repository
Interface ReservationRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<Reservation,,UUID> org.springframework.data.jpa.repository.JpaRepository<Reservation,,UUID> org.springframework.data.repository.ListCrudRepository<Reservation,,UUID> org.springframework.data.repository.ListPagingAndSortingRepository<Reservation,,UUID> org.springframework.data.repository.PagingAndSortingRepository<Reservation,,UUID> org.springframework.data.repository.query.QueryByExampleExecutor<Reservation>,org.springframework.data.repository.Repository<Reservation,UUID>
@Repository
public interface ReservationRepository
extends org.springframework.data.jpa.repository.JpaRepository<Reservation,UUID>
Repository interface for the Reservation entity.
This interface extends JpaRepository and provides methods to perform CRUD operations on the Reservation entity.
It is annotated with @Repository to indicate that it is a Spring Data repository.
JpaRepository: This interface is a JPA specific extension of Repository. It contains the full API of CrudRepository and PagingAndSortingRepository. So it contains API for basic CRUD operations and also API for pagination and sorting.
Reservation: This is the entity class for which this repository interface is created. It represents the reservation table in the database.
UUID: This is the type of the primary key of the Reservation entity.
-
Method Summary
Modifier and TypeMethodDescriptionfindByEventId(UUID eventId) This method is used to fetch all reservations made for a specific event.findByPrenotationCode(String prenotationCode) This method is used to fetch a reservation using its prenotation code.findByUserId(UUID userId) This method is used to fetch all reservations made by a specific user.findByUserIdAndEventId(UUID userId, UUID eventId) This method is used to fetch a reservation using its prenotation code and the user ID.Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, saveMethods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.repository.ListCrudRepository
findAll, findAllById, saveAllMethods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Method Details
-
findByUserId
This method is used to fetch all reservations made by a specific user. Spring Data JPA will automatically implement this method using a query derived from the method name.- Parameters:
userId- The ID of the user for whom to fetch reservations.- Returns:
- A list of Reservation objects that were made by the user with the given ID.
-
findByPrenotationCode
This method is used to fetch a reservation using its prenotation code. Spring Data JPA will automatically implement this method using a query derived from the method name.- Parameters:
prenotationCode- The prenotation code of the reservation to fetch.- Returns:
- The Reservation object that has the given prenotation code. If no such reservation exists, this method returns null.
-
findByUserIdAndEventId
This method is used to fetch a reservation using its prenotation code and the user ID. Spring Data JPA will automatically implement this method using a query derived from the method name.- Parameters:
userId- The ID of the user for whom to fetch reservations.eventId- The ID of the event for which to fetch reservations.- Returns:
- The Reservation object that belongs to the user with the given ID and has the given event ID. If no such reservation exists, this method returns an empty Optional.
-
findByEventId
This method is used to fetch all reservations made for a specific event. Spring Data JPA will automatically implement this method using a query derived from the method name.- Parameters:
eventId- The ID of the event for which to fetch reservations.- Returns:
- A list of Reservation objects that were made for the event with the given ID.
-