Package app.YUP.repository
Interface EventRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<Event,,UUID> org.springframework.data.jpa.repository.JpaRepository<Event,,UUID> org.springframework.data.repository.ListCrudRepository<Event,,UUID> org.springframework.data.repository.ListPagingAndSortingRepository<Event,,UUID> org.springframework.data.repository.PagingAndSortingRepository<Event,,UUID> org.springframework.data.repository.query.QueryByExampleExecutor<Event>,org.springframework.data.repository.Repository<Event,UUID>
@Repository
public interface EventRepository
extends org.springframework.data.jpa.repository.JpaRepository<Event,UUID>
Repository interface for the Event entity.
This interface extends JpaRepository and provides methods to perform CRUD operations on the Event entity.
It is annotated with @Repository to indicate that it is a Spring Data repository.
-
Method Summary
Modifier and TypeMethodDescriptionFinds an event by its ID.findByName(String name) Finds an event by its name.findByOwner(User owner) Finds events by their owner.voidupdateParticipantsById(UUID id, int participants) Updates the number of participants for an event by its ID.Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, 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
-
findById
Finds an event by its ID. -
findByOwner
Finds events by their owner.- Parameters:
owner- the owner of the events- Returns:
- a list of events owned by the given user
-
findByName
Finds an event by its name.- Parameters:
name- the name of the event- Returns:
- an Optional containing the event if found, or an empty Optional if not found
-
updateParticipantsById
@Modifying @Query("update Event e set e.participants = :participants where e.id = :id") void updateParticipantsById(UUID id, int participants) Updates the number of participants for an event by its ID.- Parameters:
id- the ID of the eventparticipants- the new number of participants
-