Skip to content

Commit

Permalink
Skip class transformer in PersistenceUnitInfoDescriptor for native im…
Browse files Browse the repository at this point in the history
…ages

In order to restore native support with Hibernate 6.2, this
change updates the PersistenceUnitInfoDescriptor instance
created by SpringHibernateJpaPersistenceProvider in order to
skip the class transformer for native images.

Closes spring-projectsgh-30492
  • Loading branch information
sdeleuze committed May 15, 2023
1 parent 806519f commit 3cfc658
Showing 1 changed file with 9 additions and 1 deletion.
Expand Up @@ -22,6 +22,7 @@

import jakarta.persistence.EntityManagerFactory;
import jakarta.persistence.spi.PersistenceUnitInfo;
import org.hibernate.bytecode.enhance.spi.EnhancementContext;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.jpa.HibernatePersistenceProvider;
Expand Down Expand Up @@ -58,11 +59,18 @@ public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitI
mergedClassesAndPackages.addAll(smartInfo.getManagedPackages());
}
return new EntityManagerFactoryBuilderImpl(
new PersistenceUnitInfoDescriptor(info) {
new PersistenceUnitInfoDescriptor(info) {
@Override
public List<String> getManagedClassNames() {
return mergedClassesAndPackages;
}

@Override
public void pushClassTransformer(EnhancementContext enhancementContext) {
if (!NativeDetector.inNativeImage()) {
super.pushClassTransformer(enhancementContext);
}
}
}, properties).build();
}

Expand Down

0 comments on commit 3cfc658

Please sign in to comment.