Skip to content

Commit bc1ee76

Browse files
committed
Change default for new_generator_mappings to true
Closes gh-7612
1 parent 1ad318d commit bc1ee76

File tree

11 files changed

+22
-6
lines changed

11 files changed

+22
-6
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private void applyNewIdGeneratorMappings(Map<String, String> result) {
202202
this.useNewIdGeneratorMappings.toString());
203203
}
204204
else if (!result.containsKey(USE_NEW_ID_GENERATOR_MAPPINGS)) {
205-
result.put(USE_NEW_ID_GENERATOR_MAPPINGS, "false");
205+
result.put(USE_NEW_ID_GENERATOR_MAPPINGS, "true");
206206
}
207207
}
208208

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/JpaPropertiesTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,17 @@ public void useNewIdGeneratorMappingsDefault() throws Exception {
108108
Map<String, String> hibernateProperties = properties
109109
.getHibernateProperties(mockStandaloneDataSource());
110110
assertThat(hibernateProperties)
111-
.containsEntry(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "false");
111+
.containsEntry(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true");
112112
}
113113

114114
@Test
115-
public void useNewIdGeneratorMappingsTrue() throws Exception {
115+
public void useNewIdGeneratorMappingsFalse() throws Exception {
116116
JpaProperties properties = load(
117-
"spring.jpa.hibernate.use-new-id-generator-mappings:true");
117+
"spring.jpa.hibernate.use-new-id-generator-mappings:false");
118118
Map<String, String> hibernateProperties = properties
119119
.getHibernateProperties(mockStandaloneDataSource());
120120
assertThat(hibernateProperties)
121-
.containsEntry(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true");
121+
.containsEntry(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "false");
122122
}
123123

124124
@Test

spring-boot-samples/spring-boot-sample-data-jpa/src/test/java/sample/data/jpa/SampleDataJpaApplicationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
@SpringBootTest
4949
// Enable JMX so we can test the MBeans (you can't do this in a properties file)
5050
@TestPropertySource(properties = { "spring.jmx.enabled:true",
51-
"spring.datasource.jmx-enabled:true" })
51+
"spring.datasource.jmx-enabled:true", "spring.jpa.hibernate.use-new-id-generator-mappings=false" })
5252
@ActiveProfiles("scratch")
5353
// Separate profile for web tests to avoid clashing databases
5454
public class SampleDataJpaApplicationTests {

spring-boot-samples/spring-boot-sample-data-jpa/src/test/java/sample/data/jpa/service/CityRepositoryIntegrationTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.springframework.boot.test.context.SpringBootTest;
2424
import org.springframework.data.domain.Page;
2525
import org.springframework.data.domain.PageRequest;
26+
import org.springframework.test.context.TestPropertySource;
2627
import org.springframework.test.context.junit4.SpringRunner;
2728

2829
import static org.assertj.core.api.Assertions.assertThat;
@@ -34,6 +35,7 @@
3435
*/
3536
@RunWith(SpringRunner.class)
3637
@SpringBootTest
38+
@TestPropertySource(properties = "spring.jpa.hibernate.use-new-id-generator-mappings=false")
3739
public class CityRepositoryIntegrationTests {
3840

3941
@Autowired

spring-boot-samples/spring-boot-sample-data-jpa/src/test/java/sample/data/jpa/service/HotelRepositoryIntegrationTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.springframework.data.domain.Page;
3131
import org.springframework.data.domain.PageRequest;
3232
import org.springframework.data.domain.Sort.Direction;
33+
import org.springframework.test.context.TestPropertySource;
3334
import org.springframework.test.context.junit4.SpringRunner;
3435

3536
import static org.assertj.core.api.Assertions.assertThat;
@@ -41,6 +42,7 @@
4142
*/
4243
@RunWith(SpringRunner.class)
4344
@SpringBootTest
45+
@TestPropertySource(properties = "spring.jpa.hibernate.use-new-id-generator-mappings=false")
4446
public class HotelRepositoryIntegrationTests {
4547

4648
@Autowired

spring-boot-samples/spring-boot-sample-data-rest/src/test/java/sample/data/rest/SampleDataRestApplicationTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.springframework.beans.factory.annotation.Autowired;
2424
import org.springframework.boot.test.context.SpringBootTest;
2525
import org.springframework.test.context.ActiveProfiles;
26+
import org.springframework.test.context.TestPropertySource;
2627
import org.springframework.test.context.junit4.SpringRunner;
2728
import org.springframework.test.web.servlet.MockMvc;
2829
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
@@ -44,6 +45,7 @@
4445
*/
4546
@RunWith(SpringRunner.class)
4647
@SpringBootTest
48+
@TestPropertySource(properties = "spring.jpa.hibernate.use-new-id-generator-mappings=false")
4749
@ActiveProfiles("scratch")
4850
// Separate profile for web tests to avoid clashing databases
4951
public class SampleDataRestApplicationTests {

spring-boot-samples/spring-boot-sample-data-rest/src/test/java/sample/data/rest/service/CityRepositoryIntegrationTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.springframework.boot.test.context.SpringBootTest;
2525
import org.springframework.data.domain.Page;
2626
import org.springframework.data.domain.PageRequest;
27+
import org.springframework.test.context.TestPropertySource;
2728
import org.springframework.test.context.junit4.SpringRunner;
2829

2930
import static org.assertj.core.api.Assertions.assertThat;
@@ -36,6 +37,7 @@
3637
*/
3738
@RunWith(SpringRunner.class)
3839
@SpringBootTest
40+
@TestPropertySource(properties = "spring.jpa.hibernate.use-new-id-generator-mappings=false")
3941
public class CityRepositoryIntegrationTests {
4042

4143
@Autowired

spring-boot-samples/spring-boot-sample-flyway/src/test/java/sample/flyway/SampleFlywayApplicationTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@
2222
import org.springframework.beans.factory.annotation.Autowired;
2323
import org.springframework.boot.test.context.SpringBootTest;
2424
import org.springframework.jdbc.core.JdbcTemplate;
25+
import org.springframework.test.context.TestPropertySource;
2526
import org.springframework.test.context.junit4.SpringRunner;
2627

2728
import static org.assertj.core.api.Assertions.assertThat;
2829

2930
@RunWith(SpringRunner.class)
3031
@SpringBootTest
32+
@TestPropertySource(properties = "spring.jpa.hibernate.use-new-id-generator-mappings=false")
3133
public class SampleFlywayApplicationTests {
3234

3335
@Autowired

spring-boot-samples/spring-boot-sample-jpa/src/test/java/sample/jpa/SampleJpaApplicationTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import org.springframework.beans.factory.annotation.Autowired;
2424
import org.springframework.boot.test.context.SpringBootTest;
25+
import org.springframework.test.context.TestPropertySource;
2526
import org.springframework.test.context.junit4.SpringRunner;
2627
import org.springframework.test.context.web.WebAppConfiguration;
2728
import org.springframework.test.web.servlet.MockMvc;
@@ -40,6 +41,7 @@
4041
*/
4142
@RunWith(SpringRunner.class)
4243
@SpringBootTest
44+
@TestPropertySource(properties = "spring.jpa.hibernate.use-new-id-generator-mappings=false")
4345
@WebAppConfiguration
4446
public class SampleJpaApplicationTests {
4547

spring-boot-samples/spring-boot-sample-jpa/src/test/java/sample/jpa/repository/JpaNoteRepositoryIntegrationTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import org.springframework.beans.factory.annotation.Autowired;
2525
import org.springframework.boot.test.context.SpringBootTest;
26+
import org.springframework.test.context.TestPropertySource;
2627
import org.springframework.test.context.junit4.SpringRunner;
2728
import org.springframework.transaction.annotation.Transactional;
2829

@@ -35,6 +36,7 @@
3536
*/
3637
@RunWith(SpringRunner.class)
3738
@SpringBootTest
39+
@TestPropertySource(properties = "spring.jpa.hibernate.use-new-id-generator-mappings=false")
3840
@Transactional
3941
public class JpaNoteRepositoryIntegrationTests {
4042

spring-boot-samples/spring-boot-sample-jpa/src/test/java/sample/jpa/repository/JpaTagRepositoryIntegrationTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import org.springframework.beans.factory.annotation.Autowired;
2525
import org.springframework.boot.test.context.SpringBootTest;
26+
import org.springframework.test.context.TestPropertySource;
2627
import org.springframework.test.context.junit4.SpringRunner;
2728
import org.springframework.transaction.annotation.Transactional;
2829

@@ -35,6 +36,7 @@
3536
*/
3637
@RunWith(SpringRunner.class)
3738
@SpringBootTest
39+
@TestPropertySource(properties = "spring.jpa.hibernate.use-new-id-generator-mappings=false")
3840
@Transactional
3941
public class JpaTagRepositoryIntegrationTests {
4042

0 commit comments

Comments
 (0)