Remove deprecated JPA_METAMODEL_GENERATION and JPA_METAMODEL_POPULATION from AvailableSettings

Signed-off-by: Jan Schatteman <jschatte@redhat.com>
This commit is contained in:
Jan Schatteman 2021-11-11 22:49:30 +01:00 committed by Jan Schatteman
parent 60a3c08563
commit db12d5a17a
10 changed files with 10 additions and 129 deletions

View File

@ -1152,15 +1152,6 @@ XML configuration file to use to configure Hibernate.
If true, the persistence context will be discarded (think `clear()` when the method is called). If true, the persistence context will be discarded (think `clear()` when the method is called).
Otherwise, the persistence context will stay alive till the transaction completion: all objects will remain managed, and any change will be synchronized with the database (default to false, ie wait for transaction completion). Otherwise, the persistence context will stay alive till the transaction completion: all objects will remain managed, and any change will be synchronized with the database (default to false, ie wait for transaction completion).
`*hibernate.ejb.metamodel.population*` (e.g. `enabled` or `disabled`, or `ignoreUnsupported` (default value))::
Setting that indicates whether to build the Jakarta Persistence types.
+
Accepts three values:
+
enabled::: Do the build.
disabled::: Do not do the build.
ignoreUnsupported::: Do the build, but ignore any non-Jakarta Persistence features that would otherwise result in a failure (e.g. `@Any` annotation).
`*hibernate.jpa.static_metamodel.population*` (e.g. `enabled` or `disabled`, or `skipUnsupported` (default value)):: `*hibernate.jpa.static_metamodel.population*` (e.g. `enabled` or `disabled`, or `skipUnsupported` (default value))::
Setting that controls whether we seek out Jakarta Persistence _static metamodel_ classes and populate them. Setting that controls whether we seek out Jakarta Persistence _static metamodel_ classes and populate them.
+ +

View File

@ -269,32 +269,6 @@ public interface AvailableSettings {
@Deprecated @Deprecated
String ENVIRONMENT_CLASSLOADER = "hibernate.classLoader.environment"; String ENVIRONMENT_CLASSLOADER = "hibernate.classLoader.environment";
/**
* @deprecated use {@link #JPA_METAMODEL_POPULATION} instead.
*/
@Deprecated
String JPA_METAMODEL_GENERATION = "hibernate.ejb.metamodel.generation";
/**
* Setting that indicates whether to build the JPA types. Accepts
* 3 values:<ul>
* <li>
* <b>enabled</b> - Do the build
* </li>
* <li>
* <b>disabled</b> - Do not do the build
* </li>
* <li>
* <b>ignoreUnsupported</b> - Do the build, but ignore any non-JPA features that would otherwise
* result in a failure.
* </li>
* </ul>
*
*
*/
@Deprecated
String JPA_METAMODEL_POPULATION = "hibernate.ejb.metamodel.population";
/** /**
* Setting that controls whether we seek out JPA "static metamodel" classes and populate them. Accepts * Setting that controls whether we seek out JPA "static metamodel" classes and populate them. Accepts
* 3 values:<ul> * 3 values:<ul>

View File

@ -1,52 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.metamodel.internal;
import java.util.Map;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.internal.log.DeprecationLogger;
import org.hibernate.internal.util.config.ConfigurationHelper;
/**
* @author Steve Ebersole
*/
public enum JpaMetaModelPopulationSetting {
ENABLED,
DISABLED,
IGNORE_UNSUPPORTED;
public static JpaMetaModelPopulationSetting parse(String setting) {
if ( "enabled".equalsIgnoreCase( setting ) ) {
return ENABLED;
}
else if ( "disabled".equalsIgnoreCase( setting ) ) {
return DISABLED;
}
else {
return IGNORE_UNSUPPORTED;
}
}
public static JpaMetaModelPopulationSetting determineJpaMetaModelPopulationSetting(Map configurationValues) {
String setting = ConfigurationHelper.getString(
AvailableSettings.JPA_METAMODEL_POPULATION,
configurationValues,
null
);
if ( setting == null ) {
setting = ConfigurationHelper.getString( AvailableSettings.JPA_METAMODEL_GENERATION, configurationValues, null );
if ( setting != null ) {
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
AvailableSettings.JPA_METAMODEL_GENERATION,
AvailableSettings.JPA_METAMODEL_POPULATION
);
}
}
return JpaMetaModelPopulationSetting.parse( setting );
}
}

View File

@ -9,7 +9,6 @@ package org.hibernate.metamodel.internal;
import java.util.Map; import java.util.Map;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.internal.log.DeprecationLogger;
import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.internal.util.config.ConfigurationHelper;
/** /**
@ -61,32 +60,6 @@ public enum JpaStaticMetaModelPopulationSetting {
return setting; return setting;
} }
final String legacySetting1 = ConfigurationHelper.getString(
AvailableSettings.JPA_METAMODEL_POPULATION,
configurationValues,
null
);
if ( legacySetting1 != null ) {
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
AvailableSettings.JPA_METAMODEL_POPULATION,
AvailableSettings.STATIC_METAMODEL_POPULATION
);
return legacySetting1;
}
final String legacySetting2 = ConfigurationHelper.getString(
AvailableSettings.JPA_METAMODEL_GENERATION,
configurationValues,
null
);
if ( legacySetting2 != null ) {
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
AvailableSettings.JPA_METAMODEL_GENERATION,
AvailableSettings.STATIC_METAMODEL_POPULATION
);
return legacySetting1;
}
return null; return null;
} }
} }

View File

@ -76,7 +76,7 @@ public abstract class AbstractJpaMetamodelPopulationTest extends BaseEntityManag
@Override @Override
protected void addConfigOptions(Map options) { protected void addConfigOptions(Map options) {
super.addConfigOptions( options ); super.addConfigOptions( options );
options.put( AvailableSettings.JPA_METAMODEL_POPULATION, getJpaMetamodelPopulationValue() ); options.put( AvailableSettings.STATIC_METAMODEL_POPULATION, getJpaMetamodelPopulationValue() );
} }
@Test @Test
@ -120,7 +120,7 @@ public abstract class AbstractJpaMetamodelPopulationTest extends BaseEntityManag
assertEquals( 8, metamodel.getManagedTypes().size() ); assertEquals( 8, metamodel.getManagedTypes().size() );
} }
else { else {
// When ignoreUnsupported is used, any managed-type that refers to a dynamic-map entity type // When skipUnsupported is used, any managed-type that refers to a dynamic-map entity type
// or a managed type that is owned by said dynamic-map entity type should be excluded. // or a managed type that is owned by said dynamic-map entity type should be excluded.
// Therefore this collection should only include 3 elements // Therefore this collection should only include 3 elements
// EntityType(SimpleAnnotated) // EntityType(SimpleAnnotated)

View File

@ -12,9 +12,9 @@ import org.hibernate.testing.TestForIssue;
* @author Chris Cranford * @author Chris Cranford
*/ */
@TestForIssue(jiraKey = "HHH-12871") @TestForIssue(jiraKey = "HHH-12871")
public class JpaMetamodelIgnoreUnsupportedPopulationTest extends AbstractJpaMetamodelPopulationTest { public class JpaMetamodelskipUnsupportedPopulationTest extends AbstractJpaMetamodelPopulationTest {
@Override @Override
protected String getJpaMetamodelPopulationValue() { protected String getJpaMetamodelPopulationValue() {
return "ignoreUnsupported"; return "skipUnsupported";
} }
} }

View File

@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test;
* @author Brad Koehn * @author Brad Koehn
*/ */
@Jpa( @Jpa(
integrationSettings = { @Setting(name = AvailableSettings.JPA_METAMODEL_POPULATION, value = "enabled") }, integrationSettings = { @Setting(name = AvailableSettings.STATIC_METAMODEL_POPULATION, value = "enabled") },
xmlMappings = { "org/hibernate/orm/test/jpa/criteria/paths/PolicyAndDistribution.hbm.xml" } xmlMappings = { "org/hibernate/orm/test/jpa/criteria/paths/PolicyAndDistribution.hbm.xml" }
) )
public class SingularAttributeJoinTest { public class SingularAttributeJoinTest {

View File

@ -33,8 +33,8 @@ import static org.hamcrest.Matchers.nullValue;
) )
@ServiceRegistry( @ServiceRegistry(
settings = @Setting( settings = @Setting(
name = AvailableSettings.JPA_METAMODEL_POPULATION, name = AvailableSettings.STATIC_METAMODEL_POPULATION,
value = "ignoreUnsupported" value = "skipUnsupported"
) )
) )
@DomainModel( annotatedClasses = BasicContributorTests.MainEntity.class ) @DomainModel( annotatedClasses = BasicContributorTests.MainEntity.class )

View File

@ -28,7 +28,7 @@ public class IdClassTest extends BaseCoreFunctionalTestCase {
@Override @Override
protected void configure(Configuration configuration) { protected void configure(Configuration configuration) {
// the Customer entity has a composite id that is not embeddable ( not supported by JPA ). // the Customer entity has a composite id that is not embeddable ( not supported by JPA ).
configuration.setProperty( AvailableSettings.JPA_METAMODEL_POPULATION, "disabled" ); configuration.setProperty( AvailableSettings.STATIC_METAMODEL_POPULATION, "disabled" );
} }
@Test @Test

View File

@ -10,17 +10,13 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;
import org.hibernate.envers.DefaultRevisionEntity;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.metamodel.RuntimeMetamodels; import org.hibernate.metamodel.RuntimeMetamodels;
import org.hibernate.metamodel.model.domain.EntityDomainType; import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.DomainModelScope;
import org.hibernate.testing.orm.junit.ServiceRegistry; import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
@ -28,7 +24,6 @@ import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.notNullValue;
/** /**
@ -36,8 +31,8 @@ import static org.hamcrest.Matchers.notNullValue;
*/ */
@ServiceRegistry( @ServiceRegistry(
settings = @Setting( settings = @Setting(
name = AvailableSettings.JPA_METAMODEL_POPULATION, name = AvailableSettings.STATIC_METAMODEL_POPULATION,
value = "ignoreUnsupported" value = "skipUnsupported"
) )
) )
@DomainModel( @DomainModel(