Interface UserRepository

All Superinterfaces:
org.springframework.data.repository.CrudRepository<User,Long>, org.springframework.data.repository.Repository<User,Long>

public interface UserRepository extends org.springframework.data.repository.CrudRepository<User,Long>
A repository for User objects, providing CRUD operations and a custom query for finding a user by their username and getting their associated budget ID.
Since:
16.04.2023
Version:
16.04.2023
Author:
Group19
  • Method Summary

    Modifier and Type
    Method
    Description
    Finds a user by their username.
    Retrieves the budget ID associated with the given username.

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

    count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findAll, findAllById, findById, save, saveAll
  • Method Details

    • findByUsername

      Optional<User> findByUsername(String username)
      Finds a user by their username.
      Parameters:
      username - The username of the user to find.
      Returns:
      An Optional containing the User object if found, otherwise an empty Optional.
    • getBudgetByUsername

      @Query(value="select u.bid from user u where u.username = ?1", nativeQuery=true) Optional<String> getBudgetByUsername(String username)
      Retrieves the budget ID associated with the given username.
      Parameters:
      username - The username of the user whose budget ID to retrieve.
      Returns:
      An Optional containing the budget ID as a String if found, otherwise an empty Optional.