Set hibernate.bytecode.provider to none on native image

Closes gh-29140
This commit is contained in:
Sébastien Deleuze 2022-09-13 10:18:25 +02:00
parent 6fed342543
commit a711ed59f6
1 changed files with 10 additions and 1 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,10 +23,12 @@ import java.util.Map;
import jakarta.persistence.EntityManagerFactory; import jakarta.persistence.EntityManagerFactory;
import jakarta.persistence.spi.PersistenceUnitInfo; import jakarta.persistence.spi.PersistenceUnitInfo;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.jpa.HibernatePersistenceProvider; import org.hibernate.jpa.HibernatePersistenceProvider;
import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl; import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl;
import org.hibernate.jpa.boot.internal.PersistenceUnitInfoDescriptor; import org.hibernate.jpa.boot.internal.PersistenceUnitInfoDescriptor;
import org.springframework.core.NativeDetector;
import org.springframework.orm.jpa.persistenceunit.SmartPersistenceUnitInfo; import org.springframework.orm.jpa.persistenceunit.SmartPersistenceUnitInfo;
/** /**
@ -36,11 +38,18 @@ import org.springframework.orm.jpa.persistenceunit.SmartPersistenceUnitInfo;
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @author Joris Kuipers * @author Joris Kuipers
* @author Sebastien Deleuze
* @since 4.1 * @since 4.1
* @see Configuration#addPackage * @see Configuration#addPackage
*/ */
class SpringHibernateJpaPersistenceProvider extends HibernatePersistenceProvider { class SpringHibernateJpaPersistenceProvider extends HibernatePersistenceProvider {
static {
if (NativeDetector.inNativeImage()) {
System.setProperty(Environment.BYTECODE_PROVIDER, Environment.BYTECODE_PROVIDER_NAME_NONE);
}
}
@Override @Override
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo info, Map properties) { public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo info, Map properties) {