|
113 | 113 | import org.springframework.orm.jpa.persistenceunit.ManagedClassNameFilter; |
114 | 114 | import org.springframework.orm.jpa.persistenceunit.PersistenceManagedTypes; |
115 | 115 | import org.springframework.orm.jpa.persistenceunit.PersistenceUnitManager; |
| 116 | +import org.springframework.orm.jpa.persistenceunit.PersistenceUnitPostProcessor; |
116 | 117 | import org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter; |
117 | 118 | import org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor; |
118 | 119 | import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; |
@@ -350,6 +351,19 @@ void customPersistenceUnitPostProcessors() { |
350 | 351 | }); |
351 | 352 | } |
352 | 353 |
|
| 354 | + @Test |
| 355 | + void shouldProcessAllPersistenceUnitPostProcessorsDeclaredAsBeans() { |
| 356 | + this.contextRunner.withUserConfiguration(TestConfigurationWithMultipleCustomPersistenceUnitPostProcessors.class) |
| 357 | + .run((context) -> { |
| 358 | + LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = context |
| 359 | + .getBean(LocalContainerEntityManagerFactoryBean.class); |
| 360 | + PersistenceUnitInfo persistenceUnitInfo = entityManagerFactoryBean.getPersistenceUnitInfo(); |
| 361 | + assertThat(persistenceUnitInfo).isNotNull(); |
| 362 | + assertThat(persistenceUnitInfo.getManagedClassNames()).contains( |
| 363 | + "customized.attribute.converter.class.name", "customized.attribute.converter.class.othername"); |
| 364 | + }); |
| 365 | + } |
| 366 | + |
353 | 367 | @Test |
354 | 368 | void customManagedClassNameFilter() { |
355 | 369 | this.contextRunner.withBean(ManagedClassNameFilter.class, () -> (s) -> !s.endsWith("City")) |
@@ -1149,6 +1163,24 @@ EntityManagerFactoryBuilderCustomizer entityManagerFactoryBuilderCustomizer() { |
1149 | 1163 |
|
1150 | 1164 | } |
1151 | 1165 |
|
| 1166 | + @Configuration(proxyBeanMethods = false) |
| 1167 | + @TestAutoConfigurationPackage(HibernateJpaAutoConfigurationTests.class) |
| 1168 | + static class TestConfigurationWithMultipleCustomPersistenceUnitPostProcessors { |
| 1169 | + |
| 1170 | + @Bean |
| 1171 | + EntityManagerFactoryBuilderCustomizer entityManagerFactoryBuilderCustomizer() { |
| 1172 | + return (builder) -> builder.addPersistenceUnitPostProcessors( |
| 1173 | + (pui) -> pui.addManagedClassName("customized.attribute.converter.class.name")); |
| 1174 | + } |
| 1175 | + |
| 1176 | + @Bean |
| 1177 | + EntityManagerFactoryBuilderCustomizer otherEntityManagerFactoryBuilderCustomizer() { |
| 1178 | + return (builder) -> builder.addPersistenceUnitPostProcessors( |
| 1179 | + (pui) -> pui.addManagedClassName("customized.attribute.converter.class.othername")); |
| 1180 | + } |
| 1181 | + |
| 1182 | + } |
| 1183 | + |
1152 | 1184 | static class CustomJpaTransactionManager extends JpaTransactionManager { |
1153 | 1185 |
|
1154 | 1186 | } |
|
0 commit comments