Interface AssetRepository

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

@Repository public interface AssetRepository extends org.springframework.data.jpa.repository.JpaRepository<Asset,Long>
Repositório para Ativos Financeiros.

Propósito: Gerenciar a persistência e busca de ativos negociáveis.

  • Method Summary

    Modifier and Type
    Method
    Description
    Busca todos os ativos associados a um ID de empresa específico.
    Busca exata por Ticker.
    Busca Unificada (Case-Insensitive) por Ticker, Nome do Ativo ou Nome da Empresa.

    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

    • findByTicker

      Optional<Asset> findByTicker(String ticker)
      Busca exata por Ticker.
      Parameters:
      ticker - O código do ativo (ex: PETR4).
      Returns:
      O ativo, se encontrado.
    • findAllByCompanyId

      List<Asset> findAllByCompanyId(Long companyId)
      Busca todos os ativos associados a um ID de empresa específico.
      Parameters:
      companyId - O ID da empresa.
      Returns:
      Uma lista de todos os ativos (ex: PETR3, PETR4) para a empresa.
    • searchUnified

      @Query("SELECT a FROM Asset a LEFT JOIN a.company c WHERE (LOWER(a.ticker) LIKE LOWER(CONCAT('%', :term, '%'))) OR (a.name IS NOT NULL AND LOWER(a.name) LIKE LOWER(CONCAT('%', :term, '%'))) OR (c.name IS NOT NULL AND LOWER(c.name) LIKE LOWER(CONCAT('%', :term, '%')))") List<Asset> searchUnified(@Param("term") String term)
      Busca Unificada (Case-Insensitive) por Ticker, Nome do Ativo ou Nome da Empresa.

      Nota de Auditoria: Utiliza LIKE %...% que pode ser lento em grandes volumes. Considerar Full Text Search.

      Parameters:
      term - Termo de busca parcial.
      Returns:
      Lista de ativos correspondentes.