Interface PaymentRepository

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

@Repository public interface PaymentRepository extends org.springframework.data.jpa.repository.JpaRepository<Payment,UUID>
This interface represents the repository for the Payment entity. It extends JpaRepository to provide methods for manipulating Payment entities. JpaRepository is a JPA-specific extension of Repository that provides methods for common database operations, such as saving, deleting, and finding records. It is annotated with @Repository to indicate that it serves as a data access layer.
  • Method Summary

    Modifier and Type
    Method
    Description
    Finds all payments associated with a specific sender account ID or any of the given sender card IDs.
    findBySenderAccountIdAndId(UUID accountId, UUID paymentId)
    Finds a payment by the sender account ID and the payment ID.
    findBySenderCardIdAndId(UUID cardId, UUID paymentId)
    Finds a payment by the sender card ID and the payment ID.
    Finds the card ID associated with a specific payment by its payment ID.

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

    count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, 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

    • findCardIdByPaymentId

      @Query("SELECT p.senderCard.id FROM Payment p WHERE p.id = :paymentId") Optional<UUID> findCardIdByPaymentId(@Param("paymentId") UUID paymentId)
      Finds the card ID associated with a specific payment by its payment ID.
      Parameters:
      paymentId - The ID of the payment for which to find the card ID.
      Returns:
      An Optional containing the card ID if found, or empty if not found.
    • findAllBySenderAccountIdOrSenderCardId

      @Query("SELECT p FROM Payment p WHERE p.senderAccount.id = :accountId OR p.senderCard.id IN :cardsIds") Optional<List<Payment>> findAllBySenderAccountIdOrSenderCardId(@Param("accountId") UUID accountId, @Param("cardsIds") List<UUID> cardsIds)
      Finds all payments associated with a specific sender account ID or any of the given sender card IDs.
      Parameters:
      accountId - The ID of the sender account.
      cardsIds - A list of sender card IDs.
      Returns:
      An Optional containing a list of payments that match the criteria, or empty if none are found.
    • findBySenderAccountIdAndId

      Optional<Payment> findBySenderAccountIdAndId(UUID accountId, UUID paymentId)
      Finds a payment by the sender account ID and the payment ID.
      Parameters:
      accountId - The ID of the sender account.
      paymentId - The ID of the payment to find.
      Returns:
      An Optional containing the payment if found, or empty if not found.
    • findBySenderCardIdAndId

      Optional<Payment> findBySenderCardIdAndId(UUID cardId, UUID paymentId)
      Finds a payment by the sender card ID and the payment ID.
      Parameters:
      cardId - The ID of the sender card.
      paymentId - The ID of the payment to find.
      Returns:
      An Optional containing the payment if found, or empty if not found.