Skip to content

Commit 154e337

Browse files
committed
DATAJPA-813 - Made JNDI EntityManagerFactory detection more lenient.
We now don't assume an expectedType property configured for every declaration of <jee:jndi-lookup /> but rather skip elements that don't have the attribute configured.
1 parent 2509955 commit 154e337

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/main/java/org/springframework/data/jpa/util/BeanDefinitionUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private static void registerEntityManagerFactoryBeanDefinition(String name,
124124
BeanDefinition definition = beanFactory.getBeanDefinition(name);
125125

126126
if (JNDI_OBJECT_FACTORY_BEAN.equals(definition.getBeanClassName())) {
127-
if (!definition.getPropertyValues().get("expectedType").equals(EntityManagerFactory.class.getName())) {
127+
if (!EntityManagerFactory.class.getName().equals(definition.getPropertyValues().get("expectedType"))) {
128128
return;
129129
}
130130
}

src/test/java/org/springframework/data/jpa/repository/support/DefaultJpaContextIntegrationTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public void bootstrapsDefaultJpaContextInSpringContainerWithEntityManagerFromJnd
133133

134134
SimpleNamingContextBuilder builder = SimpleNamingContextBuilder.emptyActivatedContextBuilder();
135135
builder.bind("some/EMF", createEntityManagerFactory("spring-data-jpa"));
136+
builder.bind("some/other/Component", new Object());
136137

137138
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("config/jpa-context-with-jndi.xml");
138139
ApplicationComponent component = context.getBean(ApplicationComponent.class);

src/test/resources/config/jpa-context-with-jndi.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
<jee:jndi-lookup id="entityManagerFactory"
1515
jndi-name="some/EMF"
1616
expected-type="javax.persistence.EntityManagerFactory" />
17-
17+
18+
<jee:jndi-lookup id="someOtherJndiBean"
19+
jndi-name="some/other/Component" />
20+
1821
<bean class="org.springframework.data.jpa.repository.support.DefaultJpaContextIntegrationTests$ApplicationComponent" autowire="constructor" />
1922

2023
</beans>

0 commit comments

Comments
 (0)