Skip to content

Commit bc8a742

Browse files
odrotbohmmp911de
authored andcommitted
Avoid invoking callbacks in fallback EntityManagerFactory creation in AOT.
This is to avoid AOT repository generation failures in cases that require advanced customization of the EntityManagerFactory, such as Spring-provided entity listeners. Closes #4069
1 parent 7332f29 commit bc8a742

File tree

1 file changed

+4
-2
lines changed
  • spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/aot

1 file changed

+4
-2
lines changed

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/aot/AotMetamodel.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.util.function.Supplier;
3131

3232
import org.hibernate.cfg.JdbcSettings;
33+
import org.hibernate.cfg.PersistenceSettings;
3334
import org.hibernate.dialect.H2Dialect;
3435
import org.hibernate.engine.jdbc.connections.internal.UserSuppliedConnectionProviderImpl;
3536
import org.hibernate.jpa.HibernatePersistenceProvider;
@@ -95,8 +96,9 @@ static Lazy<EntityManagerFactory> init(Supplier<PersistenceUnitInfoDescriptor> u
9596
return Lazy.of(() -> new EntityManagerFactoryBuilderImpl(unitInfo.get(),
9697
Map.of(JdbcSettings.DIALECT, H2Dialect.class.getName(), //
9798
JdbcSettings.ALLOW_METADATA_ON_BOOT, "false", //
98-
JdbcSettings.CONNECTION_PROVIDER, new UserSuppliedConnectionProviderImpl()))
99-
.build());
99+
JdbcSettings.CONNECTION_PROVIDER, new UserSuppliedConnectionProviderImpl(), //
100+
PersistenceSettings.JPA_CALLBACKS_ENABLED, false))
101+
.build());
100102
}
101103

102104
private Metamodel getMetamodel() {

0 commit comments

Comments
 (0)