All Superinterfaces:
org.springframework.data.repository.CrudRepository<User,UUID>, org.springframework.data.jpa.repository.JpaRepository<User,UUID>, org.springframework.data.repository.ListCrudRepository<User,UUID>, org.springframework.data.repository.ListPagingAndSortingRepository<User,UUID>, org.springframework.data.repository.PagingAndSortingRepository<User,UUID>, org.springframework.data.repository.query.QueryByExampleExecutor<User>, org.springframework.data.repository.Repository<User,UUID>

@Repository public interface UserRepository extends org.springframework.data.jpa.repository.JpaRepository<User,UUID>
  • Method Summary

    Modifier and Type
    Method
    Description
    findById(UUID userId)
    Find a user by their unique user ID
    Find all online users
    Find recently active users (online or last seen within specified time)
    void
    updateOnlineStatus(UUID userId, boolean online, Instant lastSeen)
    Update user online status

    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

      @NonNull Optional<User> findById(@NonNull UUID userId)
      Find a user by their unique user ID
      Specified by:
      findById in interface org.springframework.data.repository.CrudRepository<User,UUID>
    • findByOnlineTrue

      List<User> findByOnlineTrue()
      Find all online users
    • updateOnlineStatus

      @Modifying @Query("UPDATE User u SET u.online = :online, u.lastSeen = :lastSeen WHERE u.id = :userId") void updateOnlineStatus(@Param("userId") UUID userId, @Param("online") boolean online, @Param("lastSeen") Instant lastSeen)
      Update user online status
    • findRecentlyActiveUsers

      @Query("SELECT u FROM User u WHERE u.online = true OR u.lastSeen >= :since ORDER BY u.lastSeen DESC") List<User> findRecentlyActiveUsers(@Param("since") Instant since)
      Find recently active users (online or last seen within specified time)