Browse Source

Tolerate Hibernate 5.2

Closes gh-15100
pull/15134/head
Andy Wilkinson 7 years ago
parent
commit
bfb0886495
  1. 9
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.java
  2. 1
      spring-boot-tests/spring-boot-integration-tests/pom.xml
  3. 44
      spring-boot-tests/spring-boot-integration-tests/spring-boot-hibernate52-tests/pom.xml
  4. 29
      spring-boot-tests/spring-boot-integration-tests/spring-boot-hibernate52-tests/src/main/java/org/springframework/boot/tests/hibernate52/Hibernate52Application.java
  5. 34
      spring-boot-tests/spring-boot-integration-tests/spring-boot-hibernate52-tests/src/test/java/org/springframework/boot/tests/hibernate52/Hibernate52ApplicationTests.java

9
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.java

@ -116,8 +116,13 @@ class HibernateJpaConfiguration extends JpaBaseConfiguration { @@ -116,8 +116,13 @@ class HibernateJpaConfiguration extends JpaBaseConfiguration {
ConfigurableListableBeanFactory beanFactory,
List<HibernatePropertiesCustomizer> hibernatePropertiesCustomizers) {
List<HibernatePropertiesCustomizer> customizers = new ArrayList<>();
customizers.add((properties) -> properties.put(AvailableSettings.BEAN_CONTAINER,
new SpringBeanContainer(beanFactory)));
if (ClassUtils.isPresent(
"org.hibernate.resource.beans.container.spi.BeanContainer",
getClass().getClassLoader())) {
customizers
.add((properties) -> properties.put(AvailableSettings.BEAN_CONTAINER,
new SpringBeanContainer(beanFactory)));
}
if (physicalNamingStrategy != null || implicitNamingStrategy != null) {
customizers.add(new NamingStrategiesHibernatePropertiesCustomizer(
physicalNamingStrategy, implicitNamingStrategy));

1
spring-boot-tests/spring-boot-integration-tests/pom.xml

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
<modules>
<module>spring-boot-configuration-processor-tests</module>
<module>spring-boot-devtools-tests</module>
<module>spring-boot-hibernate52-tests</module>
<module>spring-boot-server-tests</module>
<module>spring-boot-launch-script-tests</module>
</modules>

44
spring-boot-tests/spring-boot-integration-tests/spring-boot-hibernate52-tests/pom.xml

@ -0,0 +1,44 @@ @@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-integration-tests</artifactId>
<version>${revision}</version>
</parent>
<artifactId>spring-boot-hibernate52-tests</artifactId>
<name>Spring Boot Hibernate 5.2 tests</name>
<description>${project.name}</description>
<properties>
<main.basedir>${basedir}/../../..</main.basedir>
<hibernate.version>5.2.17.Final</hibernate.version>
</properties>
<dependencies>
<!-- Compile -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- Runtime -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<!-- Test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

29
spring-boot-tests/spring-boot-integration-tests/spring-boot-hibernate52-tests/src/main/java/org/springframework/boot/tests/hibernate52/Hibernate52Application.java

@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.tests.hibernate52;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Hibernate52Application {
public static void main(String[] args) {
SpringApplication.run(Hibernate52Application.class, args);
}
}

34
spring-boot-tests/spring-boot-integration-tests/spring-boot-hibernate52-tests/src/test/java/org/springframework/boot/tests/hibernate52/Hibernate52ApplicationTests.java

@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.tests.hibernate52;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class Hibernate52ApplicationTests {
@Test
public void contextLoads() {
}
}
Loading…
Cancel
Save