Interface AccountRepository

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

@Repository public interface AccountRepository extends org.springframework.data.jpa.repository.JpaRepository<Account,Long>
Data-access layer for Account entities.
Version:
3.0.5
Author:
Stephen Prizio
  • Method Details

    • findAccountByAccountNumberAndBrokerAndUserUsername

      Optional<Account> findAccountByAccountNumberAndBrokerAndUserUsername(String accountNumber, Broker broker, String username)
      Obtains an Account for the given account number, broker, and owner username.
      Parameters:
      accountNumber - account number
      broker - Broker
      username - owner username
      Returns:
      Optional of Account
    • findAccountsByAccountNumberIn

      List<Account> findAccountsByAccountNumberIn(Collection<String> accountNumbers)
      Returns the Accounts matching the given account numbers.
      Parameters:
      accountNumbers - account numbers
      Returns:
      List of Account
    • findAccountsByStrategy

      List<Account> findAccountsByStrategy(Strategy strategy)
      Returns the Accounts assigned to the given Strategy.
      Parameters:
      strategy - Strategy
      Returns:
      List of Account
    • findAccountsByStrategyAndUser

      List<Account> findAccountsByStrategyAndUser(Strategy strategy, User user)
      Returns the Accounts assigned to the given Strategy that belong to the given User.
      Parameters:
      strategy - Strategy
      user - User
      Returns:
      List of Account
    • findOwnedByAccountNumber

      @Query("SELECT a FROM Account a\nWHERE a.accountNumber = :accountNumber\n AND a.user.id = :userId\n AND a.portfolio.active = true\n") Optional<Account> findOwnedByAccountNumber(@Param("accountNumber") String accountNumber, @Param("userId") Long userId)
      Finds the account with the given number owned by the given user.
      Parameters:
      accountNumber - account number
      userId - owning user id, null matches nothing
      Returns:
      Optional of Account
    • findActiveByPortfolioNumberAndUserId

      @Query("SELECT a FROM Account a\nWHERE a.portfolio.portfolioNumber = :portfolioNumber\n AND a.user.id = :userId\n AND a.portfolio.active = true\n AND a.active = true\n") List<Account> findActiveByPortfolioNumberAndUserId(@Param("portfolioNumber") long portfolioNumber, @Param("userId") Long userId)
      Returns the active accounts in an active portfolio owned by the given user.
      Parameters:
      portfolioNumber - portfolio number
      userId - owning user id, null matches nothing
      Returns:
      matching active accounts
    • findAccountsWhereLastTimeTradedIsBeyondLookback

      @Query("SELECT a FROM Account a WHERE a.lastTraded IS NOT NULL AND a.lastTraded < ?1") List<Account> findAccountsWhereLastTimeTradedIsBeyondLookback(LocalDateTime dateTime)
      Returns a List of Accounts who's last traded is greater than the given time span.
      Parameters:
      dateTime - LocalDateTime
      Returns:
      List of Account