Interface EventRepository

  • All Superinterfaces:
    org.springframework.data.repository.CrudRepository<Event,​Long>, org.springframework.data.jpa.repository.JpaRepository<Event,​Long>, org.springframework.data.repository.PagingAndSortingRepository<Event,​Long>, org.springframework.data.repository.query.QueryByExampleExecutor<Event>, org.springframework.data.repository.Repository<Event,​Long>

    public interface EventRepository
    extends org.springframework.data.jpa.repository.JpaRepository<Event,​Long>
    This interface extends the JpaRepository and Event entity. This interface handles searching for events using different parameters including id, event name, address, time, latitude, longitude. It also, allows us to get access to a specific event with findByIdAndPasskey(Long, String)}. Furthermore, we can delete an event too.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void deleteEventById​(Long id)
      This query allows users to delete an event by Id
      Optional<Event> findByAddress​(String address)
      This Jpa hibernate query allows users to find an event by the address.
      Optional<Event> findByIdAndPasskey​(long id, String passkey)
      This Jpa hibernate query allows users to find an event by the id and passkey.
      Optional<Event> findByIdAndUser​(long id, User user)
      This query finds an Event by the user that posted it and the event id.
      Optional<Event> findByLatitudeAndLongitude​(Double latitude, Double longitude)
      This Jpa hibernate query allows users to find an event by the latitude and longitude.
      Optional<Event> findByName​(String name)
      This JPA hibernate query allows users to find an event by its name.
      Optional<Event> findByNameAndAddress​(String name, String address)
      This JPA hibernate query allows users to find an event by its name and address.
      Optional<Event> findByTime​(Date time)
      This JPA hibernate query allows users to find an event by the time the event was created.
      List<Event> findEventsByUser​(User user)
      This Jpa hibernate query allows users to find all events they're a part of
      • Methods inherited from interface org.springframework.data.repository.CrudRepository

        count, delete, deleteAll, deleteAll, deleteById, existsById, findById, save
      • Methods inherited from interface org.springframework.data.jpa.repository.JpaRepository

        deleteAllInBatch, deleteInBatch, findAll, findAll, findAll, findAll, findAllById, flush, getOne, saveAll, saveAndFlush
      • Methods inherited from interface org.springframework.data.repository.PagingAndSortingRepository

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

        count, exists, findAll, findOne
    • Method Detail

      • findByName

        Optional<Event> findByName​(String name)
        This JPA hibernate query allows users to find an event by its name.
        Parameters:
        name - is the input parameter for this query, type String.
        Returns:
        this optionally returns an Event, if it matches by name, if not it doesn't return an Event.
      • findByNameAndAddress

        Optional<Event> findByNameAndAddress​(String name,
                                             String address)
        This JPA hibernate query allows users to find an event by its name and address.
        Parameters:
        name - is one input parameter for this query, type String.
        address - is one input parameter for this query, type String.
        Returns:
        this optionally returns an Event, if it matches by name, if not it doesn't return an Event.
      • findByTime

        Optional<Event> findByTime​(Date time)
        This JPA hibernate query allows users to find an event by the time the event was created.
        Parameters:
        time - is one input parameter for this query, type Date.
        Returns:
        this optionally returns an Event, if it matches by the time query, if not it doesn't return.
      • findByAddress

        Optional<Event> findByAddress​(String address)
        This Jpa hibernate query allows users to find an event by the address.
        Parameters:
        address - is an input parameter for this query, type String.
        Returns:
        this optionally returns an Event, if it matches by the address, if not it doesn't return.
      • findByLatitudeAndLongitude

        Optional<Event> findByLatitudeAndLongitude​(Double latitude,
                                                   Double longitude)
        This Jpa hibernate query allows users to find an event by the latitude and longitude.
        Parameters:
        latitude - is an input parameter for this query, type Double.
        longitude - is an input parameter for this query, type Double.
        Returns:
        this optionally returns an Event, if it matches by the the latitude and longitude, if not it doesn't return.
      • findByIdAndPasskey

        Optional<Event> findByIdAndPasskey​(long id,
                                           String passkey)
        This Jpa hibernate query allows users to find an event by the id and passkey.
        Parameters:
        id - is an input parameter for this query, type Long.
        passkey - is an input parameter for this query, type String.
        Returns:
        this optionally returns an Event, if it matches the
      • findEventsByUser

        List<Event> findEventsByUser​(User user)
        This Jpa hibernate query allows users to find all events they're a part of
        Parameters:
        user - is a User object
        Returns:
        a list of events
      • deleteEventById

        void deleteEventById​(Long id)
        This query allows users to delete an event by Id
        Parameters:
        id - that's associated with an Event
      • findByIdAndUser

        Optional<Event> findByIdAndUser​(long id,
                                        User user)
        This query finds an Event by the user that posted it and the event id.
        Parameters:
        id - is the primary key for event.
        user - is a User object.
        Returns:
        An event associated with the user that created the event.