HHH-16223 Deprecate HBM2DDL_DATABASE_ACTION

This commit is contained in:
Sanne Grinovero 2023-03-07 14:58:35 +00:00
parent bb751da34d
commit d0cdcb006d
24 changed files with 47 additions and 51 deletions

View File

@ -1639,20 +1639,10 @@ public interface AvailableSettings {
String HBM2DDL_CONNECTION = "javax.persistence.schema-generation-connection";
/**
* Specifies whether schema generation commands for schema creation are to be determined based
* on object/relational mapping metadata, DDL scripts, or a combination of the two. See
* {@link org.hibernate.tool.schema.SourceType} for the list of legal values.
* <p>
* If no value is specified, a default is inferred as follows:
* <ul>
* <li>if source scripts are specified via {@value #HBM2DDL_CREATE_SCRIPT_SOURCE}, then
* {@link org.hibernate.tool.schema.SourceType#SCRIPT "script"} is assumed, or
* <li>otherwise, {@link org.hibernate.tool.schema.SourceType#SCRIPT "metadata"} is
* assumed.
* </ul>
*
* @deprecated Migrate to {@link #JAKARTA_HBM2DDL_CREATE_SOURCE} instead
* @see org.hibernate.tool.schema.SourceType
*/
@Deprecated
String HBM2DDL_CREATE_SOURCE = "javax.persistence.schema-generation.create-source";
/**

View File

@ -62,7 +62,7 @@ public class OneToOneJoinTableUniquenessTest extends BaseCoreFunctionalTestCase
String value = output.toPath().toString();
configuration.setProperty( AvailableSettings.HBM2DDL_SCRIPTS_CREATE_TARGET, value );
configuration.setProperty( AvailableSettings.HBM2DDL_SCRIPTS_ACTION, "create" );
configuration.setProperty( AvailableSettings.HBM2DDL_DATABASE_ACTION, "create-drop" );
configuration.setProperty( AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, "create-drop" );
configuration.setProperty( AvailableSettings.FORMAT_SQL, "false" );
}

View File

@ -49,7 +49,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
@SessionFactory(useCollectingStatementInspector = true)
@ServiceRegistry(
settings = {
@Setting(name = AvailableSettings.HBM2DDL_DATABASE_ACTION, value = "create-drop")
@Setting(name = AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, value = "create-drop")
}
)
public class EagerToOneWithJoinFetchModeTests {

View File

@ -46,7 +46,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
@SessionFactory(useCollectingStatementInspector = true)
@ServiceRegistry(
settings = {
@Setting(name = AvailableSettings.HBM2DDL_DATABASE_ACTION, value = "create-drop")
@Setting(name = AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, value = "create-drop")
}
)
public class EagerToOneWithSelectFetchModeTests {

View File

@ -47,7 +47,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
@SessionFactory(useCollectingStatementInspector = true)
@ServiceRegistry(
settings = {
@Setting(name = AvailableSettings.HBM2DDL_DATABASE_ACTION, value = "create-drop")
@Setting(name = AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, value = "create-drop")
}
)
public class LazyToOneWithJoinFetchModeTests {

View File

@ -47,7 +47,7 @@ import static org.hibernate.testing.hamcrest.CollectionMatchers.hasSize;
@SessionFactory(useCollectingStatementInspector = true)
@ServiceRegistry(
settings = {
@Setting(name = AvailableSettings.HBM2DDL_DATABASE_ACTION, value = "create-drop")
@Setting(name = AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, value = "create-drop")
}
)
public class LazyToOneWithSelectFetchModeTests {

View File

@ -44,7 +44,7 @@ import org.junit.jupiter.api.Test;
)
@ServiceRegistry(
settings = {
@Setting(name = AvailableSettings.HBM2DDL_DATABASE_ACTION, value = "create-drop")
@Setting(name = AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, value = "create-drop")
}
)
@SessionFactory

View File

@ -37,7 +37,7 @@ import static org.junit.Assert.assertThat;
)
@ServiceRegistry(
settings = {
@Setting(name = AvailableSettings.HBM2DDL_DATABASE_ACTION, value = "create-drop")
@Setting(name = AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, value = "create-drop")
}
)
@SessionFactory

View File

@ -49,7 +49,7 @@ public class JpaSchemaGeneratorTest extends EntityManagerFactoryBasedFunctionalT
@TestForIssue(jiraKey = "HHH-8271")
public void testSqlLoadScriptSourceClasspath() {
Map<Object, Object> settings = buildSettings();
settings.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, "create-drop" );
settings.put( AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, "create-drop" );
settings.put( AvailableSettings.HBM2DDL_LOAD_SCRIPT_SOURCE, getLoadSqlScript() );
doTest( settings );
}
@ -59,7 +59,7 @@ public class JpaSchemaGeneratorTest extends EntityManagerFactoryBasedFunctionalT
@TestForIssue(jiraKey = "HHH-8271")
public void testSqlLoadScriptSourceUrl() {
Map<Object, Object> settings = buildSettings();
settings.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, "create-drop" );
settings.put( AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, "create-drop" );
settings.put( AvailableSettings.HBM2DDL_LOAD_SCRIPT_SOURCE, getResourceUrlString( getLoadSqlScript() ) );
doTest( settings );
}
@ -68,8 +68,8 @@ public class JpaSchemaGeneratorTest extends EntityManagerFactoryBasedFunctionalT
@TestForIssue(jiraKey = "HHH-8271")
public void testSqlCreateScriptSourceClasspath() {
Map<Object, Object> settings = buildSettings();
settings.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, "create-drop" );
settings.put( AvailableSettings.HBM2DDL_CREATE_SOURCE, "metadata-then-script" );
settings.put( AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, "create-drop" );
settings.put( AvailableSettings.JAKARTA_HBM2DDL_CREATE_SOURCE, "metadata-then-script" );
settings.put( AvailableSettings.HBM2DDL_CREATE_SCRIPT_SOURCE, getCreateSqlScript() );
doTest( settings );
}
@ -78,8 +78,8 @@ public class JpaSchemaGeneratorTest extends EntityManagerFactoryBasedFunctionalT
@TestForIssue(jiraKey = "HHH-8271")
public void testSqlCreateScriptSourceUrl() {
Map<Object, Object> settings = buildSettings();
settings.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, "create-drop" );
settings.put( AvailableSettings.HBM2DDL_CREATE_SOURCE, "metadata-then-script" );
settings.put( AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, "create-drop" );
settings.put( AvailableSettings.JAKARTA_HBM2DDL_CREATE_SOURCE, "metadata-then-script" );
settings.put( AvailableSettings.HBM2DDL_CREATE_SCRIPT_SOURCE, getResourceUrlString( getCreateSqlScript() ) );
doTest( settings );
}
@ -90,7 +90,7 @@ public class JpaSchemaGeneratorTest extends EntityManagerFactoryBasedFunctionalT
public void testSqlDropScriptSourceClasspath() {
Map<Object, Object> settings = buildSettings();
settings.put( AvailableSettings.HBM2DDL_DROP_SOURCE, "metadata-then-script" );
settings.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, "drop" );
settings.put( AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, "drop" );
settings.put( AvailableSettings.HBM2DDL_DROP_SCRIPT_SOURCE, getDropSqlScript() );
doTest( settings );
}
@ -100,7 +100,7 @@ public class JpaSchemaGeneratorTest extends EntityManagerFactoryBasedFunctionalT
public void testSqlDropScriptSourceUrl() {
Map<Object, Object> settings = buildSettings();
settings.put( AvailableSettings.HBM2DDL_DROP_SOURCE, "metadata-then-script" );
settings.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, "drop" );
settings.put( AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, "drop" );
settings.put( AvailableSettings.HBM2DDL_DROP_SCRIPT_SOURCE, getResourceUrlString( getDropSqlScript() ) );
doTest( settings );
}

View File

@ -119,7 +119,7 @@ public class SchemaDatabaseFileGenerationFailureTest {
private Map getConfig() {
final Map<Object, Object> config = Environment.getProperties();
config.put( AvailableSettings.HBM2DDL_CONNECTION, connection );
config.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, "drop" );
config.put( AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, "drop" );
config.put( AvailableSettings.HBM2DDL_HALT_ON_ERROR, true );
ArrayList<Class> classes = new ArrayList<>();

View File

@ -54,7 +54,7 @@ import static org.junit.Assert.assertTrue;
settings = {
@Setting( name = AvailableSettings.USE_SECOND_LEVEL_CACHE, value = "true" ),
@Setting( name = AvailableSettings.GENERATE_STATISTICS, value = "true" ),
@Setting( name = AvailableSettings.HBM2DDL_DATABASE_ACTION, value = "create-drop" )
@Setting( name = AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, value = "create-drop" )
}
)
@DomainModel(

View File

@ -51,7 +51,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
@ServiceRegistry(
settings = {
@Setting(name = AvailableSettings.GENERATE_STATISTICS, value = "true"),
@Setting(name = AvailableSettings.HBM2DDL_DATABASE_ACTION, value = "create-drop")
@Setting(name = AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, value = "create-drop")
}
)
public class OneToManyBidirectionalTest {

View File

@ -60,7 +60,7 @@ public class SchemaMigrationTargetScriptCreationTest extends BaseCoreFunctionalT
fail( e.getMessage() );
}
output.deleteOnExit();
configuration.setProperty( Environment.HBM2DDL_DATABASE_ACTION, "update" );
configuration.setProperty( Environment.JAKARTA_HBM2DDL_DATABASE_ACTION, "update" );
configuration.setProperty( Environment.HBM2DDL_SCRIPTS_ACTION, "update" );
configuration.setProperty( Environment.HBM2DDL_SCRIPTS_CREATE_TARGET, output.getAbsolutePath() );
}

View File

@ -25,15 +25,18 @@ import org.hibernate.testing.orm.junit.SkipForDialect;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import static org.hibernate.cfg.AvailableSettings.HBM2DDL_DATABASE_ACTION;
import static org.junit.jupiter.api.Assertions.*;
import static org.hibernate.cfg.AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
@SessionFactory
@DomainModel(annotatedClasses = { Account.class, Client.class, Record.class })
@ServiceRegistry(
settings = {
@Setting(name = HBM2DDL_DATABASE_ACTION, value = "create-drop")
@Setting(name = JAKARTA_HBM2DDL_DATABASE_ACTION, value = "create-drop")
}
)
public class TenantIdTest implements SessionFactoryProducer {

View File

@ -21,14 +21,14 @@ import org.hibernate.binder.internal.TenantIdBinder;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import static org.hibernate.cfg.AvailableSettings.HBM2DDL_DATABASE_ACTION;
import static org.hibernate.cfg.AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION;
import static org.junit.jupiter.api.Assertions.*;
@SessionFactory
@DomainModel(annotatedClasses = { Account.class, Client.class })
@ServiceRegistry(
settings = {
@Setting(name = HBM2DDL_DATABASE_ACTION, value = "create-drop")
@Setting(name = JAKARTA_HBM2DDL_DATABASE_ACTION, value = "create-drop")
}
)
public class TenantLongIdTest implements SessionFactoryProducer {

View File

@ -23,14 +23,17 @@ import org.junit.jupiter.api.Test;
import java.util.UUID;
import static org.hibernate.cfg.AvailableSettings.HBM2DDL_DATABASE_ACTION;
import static org.junit.jupiter.api.Assertions.*;
import static org.hibernate.cfg.AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
@SessionFactory
@DomainModel(annotatedClasses = { Account.class, Client.class })
@ServiceRegistry(
settings = {
@Setting(name = HBM2DDL_DATABASE_ACTION, value = "create-drop")
@Setting(name = JAKARTA_HBM2DDL_DATABASE_ACTION, value = "create-drop")
}
)
public class TenantUuidTest implements SessionFactoryProducer {

View File

@ -57,7 +57,7 @@ public class OrderSequenceGenerationTest extends BaseEnversJPAFunctionalTestCase
options.put( AvailableSettings.HBM2DDL_SCRIPTS_CREATE_TARGET, createSchema.toPath() );
options.put( AvailableSettings.HBM2DDL_SCRIPTS_DROP_TARGET, dropSchema.toPath() );
options.put( AvailableSettings.HBM2DDL_SCRIPTS_ACTION, "drop-and-create" );
options.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, "create-drop" );
options.put( AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, "create-drop" );
options.put( AvailableSettings.HBM2DDL_AUTO, "create-drop" );
}

View File

@ -65,7 +65,7 @@ public class RefreshUpdatedDataTest {
serviceRegistry = ssrb
.configure( "hibernate-config/hibernate.cfg.xml" )
.applySetting( AvailableSettings.HBM2DDL_DATABASE_ACTION, Action.CREATE_DROP )
.applySetting( AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, Action.CREATE_DROP )
.build();
final MetadataSources metadataSources = new MetadataSources( serviceRegistry );

View File

@ -119,7 +119,7 @@ public class TestHelper {
final StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder()
.configure( "hibernate-config/hibernate.cfg.xml" )
.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" )
.applySetting( AvailableSettings.HBM2DDL_DATABASE_ACTION, Action.CREATE_DROP )
.applySetting( AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, Action.CREATE_DROP )
.applySetting( AvailableSettings.HBM2DDL_AUTO, "create-drop" );
if ( H2Dialect.class.equals( DialectContext.getDialect().getClass() ) ) {

View File

@ -118,7 +118,7 @@ public class EntityManagerFactoryExtension
if ( emfAnn.exportSchema() ) {
pui.getProperties().setProperty(
AvailableSettings.HBM2DDL_DATABASE_ACTION,
AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION,
Action.CREATE_DROP.getExternalHbm2ddlName()
);
}
@ -251,7 +251,7 @@ public class EntityManagerFactoryExtension
}
final HashMap<String,Object> settings = new HashMap<>( baseProperties );
settings.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, Action.CREATE_DROP );
settings.put( AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, Action.CREATE_DROP );
final StandardServiceRegistry serviceRegistry = model.getMetadataBuildingOptions().getServiceRegistry();

View File

@ -35,7 +35,7 @@ public class SchemaCreateHelper {
public static void create(Metadata metadata, ServiceRegistry serviceRegistry) {
final Map settings = serviceRegistry.getService( ConfigurationService.class ).getSettings();
settings.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, Action.CREATE );
settings.put( AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, Action.CREATE );
SchemaManagementToolCoordinator.process(
metadata,
serviceRegistry,
@ -46,7 +46,7 @@ public class SchemaCreateHelper {
public static void createOnly(Metadata metadata, ServiceRegistry serviceRegistry) {
final Map settings = serviceRegistry.getService( ConfigurationService.class ).getSettings();
settings.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, Action.CREATE_ONLY );
settings.put( AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, Action.CREATE_ONLY );
SchemaManagementToolCoordinator.process(
metadata,
serviceRegistry,
@ -60,7 +60,7 @@ public class SchemaCreateHelper {
StandardServiceRegistry serviceRegistry,
Connection connection) {
final Map settings = serviceRegistry.getService( ConfigurationService.class ).getSettings();
settings.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, Action.CREATE );
settings.put( AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, Action.CREATE );
settings.put( AvailableSettings.HBM2DDL_CONNECTION, connection );
SchemaManagementToolCoordinator.process(
metadata,

View File

@ -32,7 +32,7 @@ public class SchemaDropHelper {
public static void drop(Metadata metadata, ServiceRegistry serviceRegistry) {
final Map settings = serviceRegistry.getService( ConfigurationService.class ).getSettings();
settings.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, Action.DROP );
settings.put( AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, Action.DROP );
SchemaManagementToolCoordinator.process(
metadata,
serviceRegistry,
@ -46,7 +46,7 @@ public class SchemaDropHelper {
StandardServiceRegistry serviceRegistry,
Connection connection) {
final Map settings = serviceRegistry.getService( ConfigurationService.class ).getSettings();
settings.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, Action.DROP );
settings.put( AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, Action.DROP );
settings.put( AvailableSettings.HBM2DDL_CONNECTION, connection );
SchemaManagementToolCoordinator.process(
metadata,

View File

@ -30,7 +30,7 @@ public class SchemaUpdateHelper {
public static void update(Metadata metadata, ServiceRegistry serviceRegistry) {
final Map settings = serviceRegistry.getService( ConfigurationService.class ).getSettings();
settings.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, Action.UPDATE );
settings.put( AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, Action.UPDATE );
SchemaManagementToolCoordinator.process(
metadata,
serviceRegistry,

View File

@ -243,7 +243,7 @@ public class SchemaExportTask extends MatchingTask {
}
if ( output.doExport() ) {
ssrBuilder.applySetting( AvailableSettings.HBM2DDL_DATABASE_ACTION, exportType.getAction() );
ssrBuilder.applySetting( AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, exportType.getAction() );
}