|
46 | 46 | import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
|
47 | 47 | import org.hibernate.internal.SessionFactoryImpl;
|
48 | 48 | import org.hibernate.jpa.HibernatePersistenceProvider;
|
49 |
| -import org.junit.jupiter.api.Disabled; |
50 | 49 | import org.junit.jupiter.api.Test;
|
51 | 50 |
|
52 | 51 | import org.springframework.aot.hint.MemberCategory;
|
|
76 | 75 | import org.springframework.context.annotation.Bean;
|
77 | 76 | import org.springframework.context.annotation.Configuration;
|
78 | 77 | import org.springframework.context.event.ContextRefreshedEvent;
|
79 |
| -import org.springframework.jdbc.core.JdbcTemplate; |
80 | 78 | import org.springframework.orm.jpa.JpaTransactionManager;
|
81 | 79 | import org.springframework.orm.jpa.JpaVendorAdapter;
|
82 | 80 | import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
@@ -510,88 +508,6 @@ void registersHintsForNamingClasses() {
|
510 | 508 | }
|
511 | 509 | }
|
512 | 510 |
|
513 |
| - @Test |
514 |
| - @Disabled("gh-40177") |
515 |
| - void whenSpringJpaGenerateDdlIsNotSetThenTableIsNotCreated() { |
516 |
| - // spring.jpa.generated-ddl defaults to false but this test still fails because |
517 |
| - // we're using an embedded database which means that HibernateProperties defaults |
518 |
| - // hibernate.hbm2ddl.auto to create-drop, replacing the |
519 |
| - // hibernate.hbm2ddl.auto=none that comes from generate-ddl being false. |
520 |
| - contextRunner().run((context) -> assertThat(tablesFrom(context)).doesNotContain("CITY")); |
521 |
| - } |
522 |
| - |
523 |
| - @Test |
524 |
| - void whenSpringJpaGenerateDdlIsTrueThenTableIsCreated() { |
525 |
| - contextRunner().withPropertyValues("spring.jpa.generate-ddl=true") |
526 |
| - .run((context) -> assertThat(tablesFrom(context)).contains("CITY")); |
527 |
| - } |
528 |
| - |
529 |
| - @Test |
530 |
| - @Disabled("gh-40177") |
531 |
| - void whenSpringJpaGenerateDdlIsFalseThenTableIsNotCreated() { |
532 |
| - // This test fails because we're using an embedded database which means that |
533 |
| - // HibernateProperties defaults hibernate.hbm2ddl.auto to create-drop, replacing |
534 |
| - // the hibernate.hbm2ddl.auto=none that comes from setting generate-ddl to false. |
535 |
| - contextRunner().withPropertyValues("spring.jpa.generate-ddl=false") |
536 |
| - .run((context) -> assertThat(tablesFrom(context)).doesNotContain("CITY")); |
537 |
| - } |
538 |
| - |
539 |
| - @Test |
540 |
| - void whenHbm2DdlAutoIsNoneThenTableIsNotCreated() { |
541 |
| - contextRunner().withPropertyValues("spring.jpa.properties.hibernate.hbm2ddl.auto=none") |
542 |
| - .run((context) -> assertThat(tablesFrom(context)).doesNotContain("CITY")); |
543 |
| - } |
544 |
| - |
545 |
| - @Test |
546 |
| - void whenSpringJpaHibernateDdlAutoIsNoneThenTableIsNotCreated() { |
547 |
| - contextRunner().withPropertyValues("spring.jpa.hibernate.ddl-auto=none") |
548 |
| - .run((context) -> assertThat(tablesFrom(context)).doesNotContain("CITY")); |
549 |
| - } |
550 |
| - |
551 |
| - @Test |
552 |
| - @Disabled("gh-40177") |
553 |
| - void whenSpringJpaGenerateDdlIsTrueAndSpringJpaHibernateDdlAutoIsNoneThenTableIsNotCreated() { |
554 |
| - // This test fails because when ddl-auto is set to none, we remove |
555 |
| - // hibernate.hbm2ddl.auto from Hibernate properties. This then allows |
556 |
| - // spring.jpa.generate-ddl to set it to create-drop |
557 |
| - contextRunner().withPropertyValues("spring.jpa.generate-ddl=true", "spring.jpa.hibernate.ddl-auto=none") |
558 |
| - .run((context) -> assertThat(tablesFrom(context)).doesNotContain("CITY")); |
559 |
| - } |
560 |
| - |
561 |
| - @Test |
562 |
| - void whenSpringJpaGenerateDdlIsTrueAndSpringJpaHibernateDdlAutoIsDropThenTableIsNotCreated() { |
563 |
| - contextRunner().withPropertyValues("spring.jpa.generate-ddl=true", "spring.jpa.hibernate.ddl-auto=drop") |
564 |
| - .run((context) -> assertThat(tablesFrom(context)).doesNotContain("CITY")); |
565 |
| - } |
566 |
| - |
567 |
| - @Test |
568 |
| - void whenSpringJpaGenerateDdlIsTrueAndJakartaSchemaGenerationIsNoneThenTableIsNotCreated() { |
569 |
| - contextRunner() |
570 |
| - .withPropertyValues("spring.jpa.generate-ddl=true", |
571 |
| - "spring.jpa.properties.jakarta.persistence.schema-generation.database.action=none") |
572 |
| - .run((context) -> { |
573 |
| - assertThat(tablesFrom(context)).doesNotContain("CITY"); |
574 |
| - }); |
575 |
| - } |
576 |
| - |
577 |
| - @Test |
578 |
| - void whenSpringJpaGenerateDdlIsTrueSpringJpaHibernateDdlAutoIsCreateAndJakartaSchemaGenerationIsNoneThenTableIsNotCreated() { |
579 |
| - contextRunner() |
580 |
| - .withPropertyValues("spring.jpa.generate-ddl=true", "spring.jpa.hibernate.ddl-auto=create", |
581 |
| - "spring.jpa.properties.jakarta.persistence.schema-generation.database.action=none") |
582 |
| - .run((context) -> { |
583 |
| - assertThat(tablesFrom(context)).doesNotContain("CITY"); |
584 |
| - }); |
585 |
| - } |
586 |
| - |
587 |
| - private List<String> tablesFrom(AssertableApplicationContext context) { |
588 |
| - DataSource dataSource = context.getBean(DataSource.class); |
589 |
| - JdbcTemplate jdbc = new JdbcTemplate(dataSource); |
590 |
| - List<String> tables = jdbc.query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES", |
591 |
| - (results, row) -> results.getString(1)); |
592 |
| - return tables; |
593 |
| - } |
594 |
| - |
595 | 511 | @Configuration(proxyBeanMethods = false)
|
596 | 512 | @TestAutoConfigurationPackage(City.class)
|
597 | 513 | @DependsOnDatabaseInitialization
|
|
0 commit comments