@Test void findOneByIdFetch() { Object id = mock(Object.class); Fetch fetch = mock(Fetch.class); transactionalRepo.findOneById(id, fetch); verify(transactionManager).getTransaction(any(TransactionDefinition.class)); verify(delegateRepository).findOneById(id, fetch); }
@Override public E findOneById(Object id) { if (TransactionSynchronizationManager.isSynchronizationActive()) { return delegate().findOneById(id); } else { return createReadonlyTransactionTemplate().execute(status -> delegate().findOneById(id)); } }
TransactionalRepositoryDecorator extends AbstractRepositoryDecorator<E> { @Override public E findOneById(Object id) { if (TransactionSynchronizationManager.isSynchronizationActive()) { return delegate().findOneById(id); } else { return createReadonlyTransactionTemplate().execute(status -> delegate().findOneById(id)); } } }
TransactionalRepositoryDecorator extends AbstractRepositoryDecorator<E> { @Override public E findOneById(Object id) { if (TransactionSynchronizationManager.isSynchronizationActive()) { return delegate().findOneById(id); } else { return createReadonlyTransactionTemplate().execute(status -> delegate().findOneById(id)); } } TransactionalRepositoryDecorator(
      Repository<E> delegateRepository, PlatformTransactionManager transactionManager); }
TransactionalRepositoryDecorator extends AbstractRepositoryDecorator<E> { @Override public E findOneById(Object id) { if (TransactionSynchronizationManager.isSynchronizationActive()) { return delegate().findOneById(id); } else { return createReadonlyTransactionTemplate().execute(status -> delegate().findOneById(id)); } } TransactionalRepositoryDecorator(
      Repository<E> delegateRepository, PlatformTransactionManager transactionManager); @Override void forEachBatched(Consumer<List<E>> consumer, int batchSize); @Override void forEachBatched(Fetch fetch, Consumer<List<E>> consumer, int batchSize); @SuppressWarnings("ConstantConditions") @Override long count(); @SuppressWarnings("ConstantConditions") @Override long count(Query<E> q); @Override Stream<E> findAll(Query<E> q); @Override E findOne(Query<E> q); @Override E findOneById(Object id); @Override E findOneById(Object id, Fetch fetch); @Override Stream<E> findAll(Stream<Object> ids); @Override Stream<E> findAll(Stream<Object> ids, Fetch fetch); @Override AggregateResult aggregate(AggregateQuery aggregateQuery); @Override void update(E entity); @Override void update(Stream<E> entities); @Override void delete(E entity); @Override void delete(Stream<E> entities); @Override void deleteById(Object id); @Override void deleteAll(Stream<Object> ids); @Override void deleteAll(); @Override void add(E entity); @Override Integer add(Stream<E> entities); @SuppressWarnings({"ConstantConditions", "NullableProblems"}) @Override Iterator<E> iterator(); }
TransactionalRepositoryDecorator extends AbstractRepositoryDecorator<E> { @Override public E findOneById(Object id) { if (TransactionSynchronizationManager.isSynchronizationActive()) { return delegate().findOneById(id); } else { return createReadonlyTransactionTemplate().execute(status -> delegate().findOneById(id)); } } TransactionalRepositoryDecorator(
      Repository<E> delegateRepository, PlatformTransactionManager transactionManager); @Override void forEachBatched(Consumer<List<E>> consumer, int batchSize); @Override void forEachBatched(Fetch fetch, Consumer<List<E>> consumer, int batchSize); @SuppressWarnings("ConstantConditions") @Override long count(); @SuppressWarnings("ConstantConditions") @Override long count(Query<E> q); @Override Stream<E> findAll(Query<E> q); @Override E findOne(Query<E> q); @Override E findOneById(Object id); @Override E findOneById(Object id, Fetch fetch); @Override Stream<E> findAll(Stream<Object> ids); @Override Stream<E> findAll(Stream<Object> ids, Fetch fetch); @Override AggregateResult aggregate(AggregateQuery aggregateQuery); @Override void update(E entity); @Override void update(Stream<E> entities); @Override void delete(E entity); @Override void delete(Stream<E> entities); @Override void deleteById(Object id); @Override void deleteAll(Stream<Object> ids); @Override void deleteAll(); @Override void add(E entity); @Override Integer add(Stream<E> entities); @SuppressWarnings({"ConstantConditions", "NullableProblems"}) @Override Iterator<E> iterator();  }