Interface UserRepository

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>
Repository interface for the User entity. This interface extends JpaRepository and provides methods to perform CRUD operations on the User entity. It is annotated with @Repository to indicate that it is a Spring Data repository.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks if a user exists by their email.
    boolean
    Checks if a user exists by their username.
    Finds a user by their ID.
    Finds a user by their username.

    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

    • findByUsername

      Optional<User> findByUsername(String username)
      Finds a user by their username.
      Parameters:
      username - the username of the user
      Returns:
      an Optional containing the user if found, or an empty Optional if not found
    • findById

      Optional<User> findById(UUID id)
      Finds a user by their ID.
      Specified by:
      findById in interface org.springframework.data.repository.CrudRepository<User,UUID>
      Parameters:
      id - the ID of the user
      Returns:
      an Optional containing the user if found, or an empty Optional if not found
    • existsByUsername

      boolean existsByUsername(String username)
      Checks if a user exists by their username.
      Parameters:
      username - the username of the user
      Returns:
      true if a user with the given username exists, false otherwise
    • existsByEmail

      boolean existsByEmail(String email)
      Checks if a user exists by their email.
      Parameters:
      email - the email of the user
      Returns:
      true if a user with the given email exists, false otherwise