|
22 | 22 | import java.util.LinkedHashMap; |
23 | 23 | import java.util.List; |
24 | 24 | import java.util.Map; |
| 25 | +import java.util.Set; |
25 | 26 | import java.util.function.Consumer; |
26 | 27 | import java.util.function.Supplier; |
27 | 28 |
|
28 | 29 | import javax.sql.DataSource; |
29 | 30 |
|
30 | 31 | import org.apache.commons.logging.Log; |
31 | 32 | import org.apache.commons.logging.LogFactory; |
| 33 | +import org.hibernate.annotations.EmbeddedTable; |
32 | 34 | import org.hibernate.boot.model.naming.ImplicitNamingStrategy; |
33 | 35 | import org.hibernate.boot.model.naming.PhysicalNamingStrategy; |
34 | 36 | import org.hibernate.boot.model.naming.PhysicalNamingStrategySnakeCaseImpl; |
| 37 | +import org.hibernate.boot.models.annotations.internal.EmbeddedTableAnnotation; |
35 | 38 | import org.hibernate.cfg.ManagedBeanSettings; |
| 39 | +import org.hibernate.event.spi.PreFlushEventListener; |
36 | 40 | import org.jspecify.annotations.Nullable; |
37 | 41 |
|
38 | 42 | import org.springframework.aot.hint.MemberCategory; |
| 43 | +import org.springframework.aot.hint.ReflectionHints; |
39 | 44 | import org.springframework.aot.hint.RuntimeHints; |
40 | 45 | import org.springframework.aot.hint.RuntimeHintsRegistrar; |
41 | 46 | import org.springframework.aot.hint.TypeHint; |
|
47 | 52 | import org.springframework.boot.context.properties.EnableConfigurationProperties; |
48 | 53 | import org.springframework.boot.hibernate.SpringImplicitNamingStrategy; |
49 | 54 | import org.springframework.boot.hibernate.SpringJtaPlatform; |
| 55 | +import org.springframework.boot.hibernate.autoconfigure.HibernateJpaConfiguration.Hibernate72RuntimeHints; |
50 | 56 | import org.springframework.boot.hibernate.autoconfigure.HibernateJpaConfiguration.HibernateRuntimeHints; |
51 | 57 | import org.springframework.boot.jdbc.SchemaManagementProvider; |
52 | 58 | import org.springframework.boot.jdbc.metadata.CompositeDataSourcePoolMetadataProvider; |
|
77 | 83 | @Configuration(proxyBeanMethods = false) |
78 | 84 | @EnableConfigurationProperties(HibernateProperties.class) |
79 | 85 | @ConditionalOnSingleCandidate(DataSource.class) |
80 | | -@ImportRuntimeHints(HibernateRuntimeHints.class) |
| 86 | +@ImportRuntimeHints({ HibernateRuntimeHints.class, Hibernate72RuntimeHints.class }) |
81 | 87 | class HibernateJpaConfiguration extends JpaBaseConfiguration { |
82 | 88 |
|
83 | 89 | private static final Log logger = LogFactory.getLog(HibernateJpaConfiguration.class); |
@@ -276,4 +282,67 @@ public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) |
276 | 282 |
|
277 | 283 | } |
278 | 284 |
|
| 285 | + static class Hibernate72RuntimeHints implements RuntimeHintsRegistrar { |
| 286 | + |
| 287 | + @Override |
| 288 | + public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) { |
| 289 | + registerLoggerHints(hints.reflection()); |
| 290 | + registerEventHints(hints.reflection()); |
| 291 | + registerAnnotationHints(hints.reflection()); |
| 292 | + } |
| 293 | + |
| 294 | + private void registerLoggerHints(ReflectionHints reflection) { |
| 295 | + reflection.registerTypes(Set.of(TypeReference.of("org.hibernate.action.internal.ActionLogging_$logger"), |
| 296 | + TypeReference.of("org.hibernate.boot.BootLogging_$logger"), |
| 297 | + TypeReference.of("org.hibernate.boot.beanvalidation.BeanValidationLogger_$logger"), |
| 298 | + TypeReference |
| 299 | + .of("org.hibernate.bytecode.enhance.spi.interceptor.BytecodeInterceptorLogging_$logger"), |
| 300 | + TypeReference.of("org.hibernate.collection.internal.CollectionLogger_$logger"), |
| 301 | + TypeReference.of("org.hibernate.context.internal.CurrentSessionLogging_$logger"), |
| 302 | + TypeReference.of("org.hibernate.engine.internal.NaturalIdLogging_$logger"), |
| 303 | + TypeReference.of("org.hibernate.engine.internal.PersistenceContextLogging_$logger"), |
| 304 | + TypeReference.of("org.hibernate.engine.internal.SessionMetricsLogger_$logger"), |
| 305 | + TypeReference.of("org.hibernate.engine.jdbc.JdbcLogging_$logger"), |
| 306 | + TypeReference.of("org.hibernate.engine.jdbc.batch.JdbcBatchLogging_$logger"), |
| 307 | + TypeReference |
| 308 | + .of("org.hibernate.engine.jdbc.connections.internal.ConnectionProviderLogging_$logger"), |
| 309 | + TypeReference.of("org.hibernate.engine.jdbc.env.internal.LobCreationLogging_$logger"), |
| 310 | + TypeReference.of("org.hibernate.engine.jdbc.spi.SQLExceptionLogging_$logger"), |
| 311 | + TypeReference.of("org.hibernate.event.internal.EntityCopyLogging_$logger"), |
| 312 | + TypeReference.of("org.hibernate.event.internal.EventListenerLogging_$logger"), |
| 313 | + TypeReference.of("org.hibernate.id.UUIDLogger_$logger"), |
| 314 | + TypeReference.of("org.hibernate.id.enhanced.OptimizerLogger_$logger"), |
| 315 | + TypeReference.of("org.hibernate.internal.SessionFactoryLogging_$logger"), |
| 316 | + TypeReference.of("org.hibernate.internal.SessionLogging_$logger"), |
| 317 | + TypeReference.of("org.hibernate.internal.log.StatisticsLogger_$logger"), |
| 318 | + TypeReference.of("org.hibernate.jpa.internal.JpaLogger_$logger"), |
| 319 | + TypeReference.of("org.hibernate.loader.ast.internal.MultiKeyLoadLogging_$logger"), |
| 320 | + TypeReference.of("org.hibernate.metamodel.mapping.MappingModelCreationLogging_$logger"), |
| 321 | + TypeReference.of("org.hibernate.query.QueryLogging_$logger"), |
| 322 | + TypeReference.of("org.hibernate.query.hql.HqlLogging_$logger"), |
| 323 | + TypeReference.of("org.hibernate.resource.jdbc.internal.LogicalConnectionLogging_$logger"), |
| 324 | + TypeReference.of("org.hibernate.resource.transaction.backend.jta.internal.JtaLogging_$logger"), |
| 325 | + TypeReference.of("org.hibernate.resource.transaction.internal.SynchronizationLogging_$logger"), |
| 326 | + TypeReference.of("org.hibernate.service.internal.ServiceLogger_$logger"), |
| 327 | + TypeReference.of("org.hibernate.sql.model.ModelMutationLogging_$logger"), |
| 328 | + TypeReference.of("org.hibernate.sql.results.graph.embeddable.EmbeddableLoadingLogger_$logger")), |
| 329 | + (hint) -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, |
| 330 | + MemberCategory.INVOKE_PUBLIC_METHODS)); |
| 331 | + } |
| 332 | + |
| 333 | + private void registerEventHints(ReflectionHints reflection) { |
| 334 | + reflection.registerType(PreFlushEventListener.class, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, |
| 335 | + MemberCategory.INVOKE_PUBLIC_METHODS); |
| 336 | + reflection.registerType(PreFlushEventListener[].class, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, |
| 337 | + MemberCategory.INVOKE_PUBLIC_METHODS); |
| 338 | + } |
| 339 | + |
| 340 | + private void registerAnnotationHints(ReflectionHints reflection) { |
| 341 | + reflection.registerType(EmbeddedTable.class, MemberCategory.INVOKE_PUBLIC_METHODS); |
| 342 | + reflection.registerType(EmbeddedTableAnnotation.class, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, |
| 343 | + MemberCategory.INVOKE_PUBLIC_METHODS); |
| 344 | + } |
| 345 | + |
| 346 | + } |
| 347 | + |
279 | 348 | } |
0 commit comments