Interface PortfolioRepository

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

@Repository public interface PortfolioRepository extends org.springframework.data.jpa.repository.JpaRepository<Portfolio, Long>
Data-access layer for Portfolio.
Version:
3.0.6
Author:
Stephen Prizio
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Deletes the Portfolio with the given id.
    findOwnedByPortfolioNumber(long portfolioNumber, Long userId)
    Returns an active portfolio owned by the given user.
    findPortfolioByPortfolioNumber(long portfolioNumber)
    Returns a Portfolio for the given portfolio number.
    findPortfolioByPortfolioNumberAndUserUsername(long portfolioNumber, String username)
    Returns a Portfolio for the given portfolio number and owner username.

    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

    • findPortfolioByPortfolioNumber

      Portfolio findPortfolioByPortfolioNumber(long portfolioNumber)
      Returns a Portfolio for the given portfolio number.
      Parameters:
      portfolioNumber - portfolio number
      Returns:
      Portfolio
    • findPortfolioByPortfolioNumberAndUserUsername

      Optional<Portfolio> findPortfolioByPortfolioNumberAndUserUsername(long portfolioNumber, String username)
      Returns a Portfolio for the given portfolio number and owner username.
      Parameters:
      portfolioNumber - portfolio number
      username - owner username
      Returns:
      Optional of Portfolio
    • findOwnedByPortfolioNumber

      @Query("SELECT p FROM Portfolio p\nWHERE p.portfolioNumber = :portfolioNumber\n AND p.user.id = :userId\n AND p.active = true\n") Optional<Portfolio> findOwnedByPortfolioNumber(@Param("portfolioNumber") long portfolioNumber, @Param("userId") Long userId)
      Returns an active portfolio owned by the given user.
      Parameters:
      portfolioNumber - portfolio number
      userId - owning user id, null matches nothing
      Returns:
      Optional of Portfolio
    • deletePortfolioById

      @Modifying(flushAutomatically=true) @Query("DELETE FROM Portfolio p WHERE p.id = :id") void deletePortfolioById(@Param("id") Long id)
      Deletes the Portfolio with the given id.
      Parameters:
      id - portfolio id