Class AbstractGenericEntityService<E extends GenericEntity, R extends org.springframework.data.jpa.repository.JpaRepository<E,Long>>

java.lang.Object
com.bluebell.greenhouse.radicle.services.AbstractGenericEntityService<E,R>
Type Parameters:
E - entity type
R - repository type
Direct Known Subclasses:
AccountLedgerService, AccountService, ConfiguredIndicatorService, ForgottenPasswordInstanceService, IndicatorCalculationInstanceService, JobService, MarketPriceFetchRequestService, MarketPriceService, PortfolioService, PositionOrderService, PositionService, PositionTransactionService, RecurringNotificationService, StrategyImplementationService, StrategyService, SymbolAliasService, SymbolEnrichmentService, SymbolService, TransactionService, UserService, WatchlistItemService, WatchlistService

public abstract class AbstractGenericEntityService<E extends GenericEntity, R extends org.springframework.data.jpa.repository.JpaRepository<E,Long>> extends Object
Generic service-layer helper for entity services.
Version:
3.0.5
Author:
Stephen Prizio
  • Constructor Details

    • AbstractGenericEntityService

      protected AbstractGenericEntityService(R entityRepository)
      Creates the service.
      Parameters:
      entityRepository - R
  • Method Details

    • refreshEntity

      public E refreshEntity(E entity)
      Refreshes the given entity from persistence when it has an id.
      Parameters:
      entity - E
      Returns:
      refreshed E
    • resolveEntity

      protected E resolveEntity(E entity, Supplier<? extends RuntimeException> notFoundExceptionFactory)
      Resolves the given entity into the managed persistence instance when it has an id.
      Parameters:
      entity - E
      notFoundExceptionFactory - factory for the exception thrown when the entity no longer exists
      Returns:
      managed E
    • resolveEntity

      protected E resolveEntity(E entity, String notFoundMessage)
      Resolves the given entity into the managed persistence instance when it has an id.
      Parameters:
      entity - E
      notFoundMessage - message used when the entity no longer exists
      Returns:
      managed E
    • resolveEntity

      protected <T extends GenericEntity> T resolveEntity(T entity, org.springframework.data.jpa.repository.JpaRepository<T,Long> repository, Supplier<? extends RuntimeException> notFoundExceptionFactory)
      Resolves the given related entity into the managed persistence instance when it has an id.
      Type Parameters:
      T - related entity type
      Parameters:
      entity - related entity
      repository - repository for the related entity type
      notFoundExceptionFactory - factory for the exception thrown when the entity no longer exists
      Returns:
      managed related entity