|
31 | 31 |
|
32 | 32 | import org.hibernate.cfg.JdbcSettings; |
33 | 33 | import org.hibernate.cfg.PersistenceSettings; |
34 | | -import org.hibernate.dialect.H2Dialect; |
| 34 | +import org.hibernate.cfg.QuerySettings; |
| 35 | +import org.hibernate.dialect.Dialect; |
35 | 36 | import org.hibernate.engine.jdbc.connections.internal.UserSuppliedConnectionProviderImpl; |
36 | 37 | import org.hibernate.jpa.HibernatePersistenceProvider; |
37 | 38 | import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl; |
38 | 39 | import org.hibernate.jpa.boot.internal.PersistenceUnitInfoDescriptor; |
39 | 40 | import org.jspecify.annotations.Nullable; |
40 | | - |
41 | 41 | import org.springframework.data.util.Lazy; |
42 | 42 | import org.springframework.orm.jpa.persistenceunit.PersistenceManagedTypes; |
43 | 43 | import org.springframework.orm.jpa.persistenceunit.SpringPersistenceUnitInfo; |
@@ -82,11 +82,12 @@ public AotMetamodel(PersistenceUnitInfo unitInfo) { |
82 | 82 | static Lazy<EntityManagerFactory> init(Supplier<PersistenceUnitInfoDescriptor> unitInfo) { |
83 | 83 |
|
84 | 84 | return Lazy.of(() -> new EntityManagerFactoryBuilderImpl(unitInfo.get(), |
85 | | - Map.of(JdbcSettings.DIALECT, H2Dialect.class.getName(), // |
| 85 | + Map.of(JdbcSettings.DIALECT, SpringDataJpaAotDialect.INSTANCE, // |
86 | 86 | JdbcSettings.ALLOW_METADATA_ON_BOOT, false, // |
87 | 87 | JdbcSettings.CONNECTION_PROVIDER, new UserSuppliedConnectionProviderImpl(), // |
| 88 | + QuerySettings.QUERY_STARTUP_CHECKING, false, // |
88 | 89 | PersistenceSettings.JPA_CALLBACKS_ENABLED, false)) |
89 | | - .build()); |
| 90 | + .build()); |
90 | 91 | } |
91 | 92 |
|
92 | 93 | private Metamodel getMetamodel() { |
@@ -130,4 +131,13 @@ public EntityManagerFactory getEntityManagerFactory() { |
130 | 131 | return entityManagerFactory.get(); |
131 | 132 | } |
132 | 133 |
|
| 134 | + /** |
| 135 | + * A {@link Dialect} to satisfy the bootstrap requirements of {@link JdbcSettings#DIALECT} during the AOT Phase. Printed |
| 136 | + * to log files (info level) when the {@link org.hibernate.engine.jdbc.env.spi.JdbcEnvironment} is created. |
| 137 | + */ |
| 138 | + @SuppressWarnings("deprecation") |
| 139 | + static class SpringDataJpaAotDialect extends Dialect { |
| 140 | + static SpringDataJpaAotDialect INSTANCE = new SpringDataJpaAotDialect(); |
| 141 | + } |
| 142 | + |
133 | 143 | } |
0 commit comments