Skip to content

Commit a711ed5

Browse files
committed
Set hibernate.bytecode.provider to none on native image
Closes gh-29140
1 parent 6fed342 commit a711ed5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

spring-orm/src/main/java/org/springframework/orm/jpa/vendor/SpringHibernateJpaPersistenceProvider.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,10 +23,12 @@
2323
import jakarta.persistence.EntityManagerFactory;
2424
import jakarta.persistence.spi.PersistenceUnitInfo;
2525
import org.hibernate.cfg.Configuration;
26+
import org.hibernate.cfg.Environment;
2627
import org.hibernate.jpa.HibernatePersistenceProvider;
2728
import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl;
2829
import org.hibernate.jpa.boot.internal.PersistenceUnitInfoDescriptor;
2930

31+
import org.springframework.core.NativeDetector;
3032
import org.springframework.orm.jpa.persistenceunit.SmartPersistenceUnitInfo;
3133

3234
/**
@@ -36,11 +38,18 @@
3638
*
3739
* @author Juergen Hoeller
3840
* @author Joris Kuipers
41+
* @author Sebastien Deleuze
3942
* @since 4.1
4043
* @see Configuration#addPackage
4144
*/
4245
class SpringHibernateJpaPersistenceProvider extends HibernatePersistenceProvider {
4346

47+
static {
48+
if (NativeDetector.inNativeImage()) {
49+
System.setProperty(Environment.BYTECODE_PROVIDER, Environment.BYTECODE_PROVIDER_NAME_NONE);
50+
}
51+
}
52+
4453
@Override
4554
@SuppressWarnings("rawtypes")
4655
public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo info, Map properties) {

0 commit comments

Comments
 (0)