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 Type
    Method
    Description
    Finds an event by its ID.
    Finds an event by its name.
    Finds events by their owner.
    void
    updateParticipantsById(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, save

    Methods inherited from interface org.springframework.data.jpa.repository.JpaRepository

    deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlush

    Methods inherited from interface org.springframework.data.repository.ListCrudRepository

    findAll, findAllById, saveAll

    Methods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository

    findAll

    Methods inherited from interface org.springframework.data.repository.PagingAndSortingRepository

    findAll

    Methods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor

    count, exists, findAll, findBy, findOne
  • Method Details

    • findById

      Optional<Event> findById(UUID id)
      Finds an event by its ID.
      Specified by:
      findById in interface org.springframework.data.repository.CrudRepository<Event,UUID>
      Parameters:
      id - the ID of the event
      Returns:
      an Optional containing the event if found, or an empty Optional if not found
    • findByOwner

      List<Event> findByOwner(User owner)
      Finds events by their owner.
      Parameters:
      owner - the owner of the events
      Returns:
      a list of events owned by the given user
    • findByName

      Optional<Event> findByName(String name)
      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 event
      participants - the new number of participants