Skip to content

Commit 6232b12

Browse files
committed
DATACMNS-880 - TransactionalRepositoryFactoryBeanSupport.setBeanFactory(…) now delegates to parent implementation.
Previously TransactionalRepositoryFactoryBeanSupport.setBeanFactory(…) didn't invoke the method of the super class preventing the BeanFactory to be propagated to the repository factory resulting in the ProjectionFactory implementation created being unaware of the BeanFactory and thus no bean references being available in projection interfaces.
1 parent 1c2e490 commit 6232b12

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/main/java/org/springframework/data/repository/core/support/TransactionalRepositoryFactoryBeanSupport.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2008-2015 the original author or authors.
2+
* Copyright 2008-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -91,6 +91,8 @@ public void setBeanFactory(BeanFactory beanFactory) {
9191

9292
Assert.isInstanceOf(ListableBeanFactory.class, beanFactory);
9393

94+
super.setBeanFactory(beanFactory);
95+
9496
ListableBeanFactory listableBeanFactory = (ListableBeanFactory) beanFactory;
9597
this.txPostProcessor = new TransactionalRepositoryProxyPostProcessor(listableBeanFactory, transactionManagerName,
9698
enableDefaultTransactions);

src/test/java/org/springframework/data/repository/core/support/TransactionRepositoryFactoryBeanSupportUnitTests.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 the original author or authors.
2+
* Copyright 2015-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
2525
import org.springframework.aop.framework.Advised;
2626
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
2727
import org.springframework.data.repository.CrudRepository;
28+
import org.springframework.test.util.ReflectionTestUtils;
2829
import org.springframework.transaction.interceptor.TransactionInterceptor;
2930

3031
/**
@@ -67,9 +68,22 @@ public void disablesDefaultTransactionsIfConfigured() {
6768
assertThat(found, is(true));
6869
}
6970

71+
/**
72+
* @see DATACMNS-880
73+
*/
74+
@Test
75+
public void propagatesBeanFactoryToSuperClass() {
76+
77+
SampleTransactionalRepositoryFactoryBean factoryBean = new SampleTransactionalRepositoryFactoryBean();
78+
factoryBean.setBeanFactory(new DefaultListableBeanFactory());
79+
80+
assertThat(ReflectionTestUtils.getField(factoryBean, RepositoryFactoryBeanSupport.class, "beanFactory"),
81+
is(notNullValue()));
82+
}
83+
7084
@SuppressWarnings({ "unchecked", "rawtypes" })
71-
static class SampleTransactionalRepositoryFactoryBean extends
72-
TransactionalRepositoryFactoryBeanSupport<CrudRepository<Object, Long>, Object, Long> {
85+
static class SampleTransactionalRepositoryFactoryBean
86+
extends TransactionalRepositoryFactoryBeanSupport<CrudRepository<Object, Long>, Object, Long> {
7387

7488
private final CrudRepository<Object, Long> repository = mock(CrudRepository.class);
7589

0 commit comments

Comments
 (0)