diff --git a/documentation/src/main/asciidoc/userguide/appendices/Configurations.adoc b/documentation/src/main/asciidoc/userguide/appendices/Configurations.adoc index 832b9d7471..333409606e 100644 --- a/documentation/src/main/asciidoc/userguide/appendices/Configurations.adoc +++ b/documentation/src/main/asciidoc/userguide/appendices/Configurations.adoc @@ -929,6 +929,7 @@ Valid options are defined by the `strategy` value of the https://docs.jboss.org/ `*hibernate.hbm2ddl.delimiter*` (e.g. `;`):: Identifies the delimiter to use to separate schema management statements in script outputs. +The default value is `;`. `*hibernate.schema_management_tool*` (e.g. A schema name):: Used to specify the `SchemaManagementTool` to use for performing schema management. The default is to use `HibernateSchemaManagementTool`. diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java b/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java index 88338b5d0f..b7efa75376 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java @@ -1859,7 +1859,8 @@ public interface AvailableSettings extends org.hibernate.jpa.AvailableSettings { String HBM2DDL_JDBC_METADATA_EXTRACTOR_STRATEGY = "hibernate.hbm2ddl.jdbc_metadata_extraction_strategy"; /** - * Identifies the delimiter to use to separate schema management statements in script outputs + * Identifies the delimiter to use to separate schema management statements in script outputs. + * The default value is ;. */ String HBM2DDL_DELIMITER = "hibernate.hbm2ddl.delimiter"; diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/HibernateSchemaManagementTool.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/HibernateSchemaManagementTool.java index 60cc75ed9a..7765e9248f 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/HibernateSchemaManagementTool.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/HibernateSchemaManagementTool.java @@ -123,7 +123,7 @@ public class HibernateSchemaManagementTool implements SchemaManagementTool, Serv JdbcContext jdbcContext, Map options, boolean needsAutoCommit) { - final String scriptDelimiter = ConfigurationHelper.getString( HBM2DDL_DELIMITER, options ); + final String scriptDelimiter = ConfigurationHelper.getString( HBM2DDL_DELIMITER, options, ";" ); final GenerationTarget[] targets = new GenerationTarget[ targetDescriptor.getTargetTypes().size() ]; @@ -156,7 +156,7 @@ public class HibernateSchemaManagementTool implements SchemaManagementTool, Serv TargetDescriptor targetDescriptor, DdlTransactionIsolator ddlTransactionIsolator, Map options) { - final String scriptDelimiter = ConfigurationHelper.getString( HBM2DDL_DELIMITER, options ); + final String scriptDelimiter = ConfigurationHelper.getString( HBM2DDL_DELIMITER, options, ";" ); final GenerationTarget[] targets = new GenerationTarget[ targetDescriptor.getTargetTypes().size() ]; diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/PostgreSQLMultipleSchemaSequenceTest.java b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/PostgreSQLMultipleSchemaSequenceTest.java index caa10efa48..ad5fc1afeb 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/PostgreSQLMultipleSchemaSequenceTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/PostgreSQLMultipleSchemaSequenceTest.java @@ -85,7 +85,7 @@ public class PostgreSQLMultipleSchemaSequenceTest extends BaseUnitTestCase { ); try(Statement statement = ddlTransactionIsolator1.getIsolatedConnection().createStatement()) { statement.execute( String.format( "DROP SCHEMA IF EXISTS %s CASCADE", extraSchemaName ) ); - statement.execute( String.format( "CREATE SCHEMA %s", extraSchemaName ) ); + statement.execute( String.format( "CREATE SCHEMA %s;", extraSchemaName ) ); try(ResultSet resultSet = statement.executeQuery( "SELECT NEXTVAL('SEQ_TEST')" )) { while ( resultSet.next() ) { @@ -156,7 +156,7 @@ public class PostgreSQLMultipleSchemaSequenceTest extends BaseUnitTestCase { assertEquals( 2 , sqlLines .stream() - .filter( s -> s.equalsIgnoreCase( "create sequence SEQ_TEST start 1 increment 1" ) ) + .filter( s -> s.equalsIgnoreCase( "create sequence SEQ_TEST start 1 increment 1;" ) ) .count() ); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/idgenerator/SequenceGenerationTest.java b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/idgenerator/SequenceGenerationTest.java index 0cc4b94641..9f604f7b99 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/idgenerator/SequenceGenerationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/idgenerator/SequenceGenerationTest.java @@ -68,12 +68,12 @@ public class SequenceGenerationTest extends BaseUnitTestCase { List commands = Files.readAllLines( output.toPath() ); assertThat( - isCommandGenerated( commands, "create table test_entity \\(id .*, primary key \\(id\\)\\)" ), + isCommandGenerated( commands, "create table test_entity \\(id .*, primary key \\(id\\)\\);" ), is( true ) ); assertThat( - isCommandGenerated( commands, "create sequence sequence_generator start with 5 increment by 3" ), + isCommandGenerated( commands, "create sequence sequence_generator start with 5 increment by 3;" ), is( true ) ); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/idgenerator/SequenceGeneratorsTest.java b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/idgenerator/SequenceGeneratorsTest.java index 236e7ff984..45941b2b72 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/idgenerator/SequenceGeneratorsTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/idgenerator/SequenceGeneratorsTest.java @@ -70,12 +70,12 @@ public class SequenceGeneratorsTest extends BaseUnitTestCase { List commands = Files.readAllLines( output.toPath() ); assertThat( - isCommandGenerated( commands, "CREATE TABLE TEST_ENTITY \\(ID .*, PRIMARY KEY \\(ID\\)\\)" ), + isCommandGenerated( commands, "CREATE TABLE TEST_ENTITY \\(ID .*, PRIMARY KEY \\(ID\\)\\);" ), is( true ) ); assertThat( - isCommandGenerated( commands, "CREATE SEQUENCE SEQUENCE_GENERATOR START WITH 5 INCREMENT BY 3" ), + isCommandGenerated( commands, "CREATE SEQUENCE SEQUENCE_GENERATOR START WITH 5 INCREMENT BY 3;" ), is( true ) ); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/idgenerator/TableGeneratorTest.java b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/idgenerator/TableGeneratorTest.java index 1cd2ca335e..249bb17cf9 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/idgenerator/TableGeneratorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/idgenerator/TableGeneratorTest.java @@ -71,13 +71,13 @@ public class TableGeneratorTest extends BaseUnitTestCase { final List commands = Files.readAllLines( output.toPath() ); - final String expectedTestEntityTableCreationCommand = "CREATE TABLE TEST_ENTITY \\(ID .*, PRIMARY KEY \\(ID\\)\\)"; + final String expectedTestEntityTableCreationCommand = "CREATE TABLE TEST_ENTITY \\(ID .*, PRIMARY KEY \\(ID\\)\\);"; assertTrue( "The command '" + expectedTestEntityTableCreationCommand + "' has not been correctly generated", isCommandGenerated( commands, expectedTestEntityTableCreationCommand ) ); - final String expectedIdTableGeneratorCreationCommand = "CREATE TABLE ID_TABLE_GENERATOR \\(PK .*, VALUE .*, PRIMARY KEY \\(PK\\)\\)"; + final String expectedIdTableGeneratorCreationCommand = "CREATE TABLE ID_TABLE_GENERATOR \\(PK .*, VALUE .*, PRIMARY KEY \\(PK\\)\\);"; assertTrue( "The command '" + expectedIdTableGeneratorCreationCommand + "' has not been correctly generated", @@ -88,7 +88,7 @@ public class TableGeneratorTest extends BaseUnitTestCase { ) ); - final String expectedInsertIntoTableGeneratorCommand = "INSERT INTO ID_TABLE_GENERATOR\\(PK, VALUE\\) VALUES \\('TEST_ENTITY_ID'," + EXPECTED_DB_INSERTED_VALUE + "\\)"; + final String expectedInsertIntoTableGeneratorCommand = "INSERT INTO ID_TABLE_GENERATOR\\(PK, VALUE\\) VALUES \\('TEST_ENTITY_ID'," + EXPECTED_DB_INSERTED_VALUE + "\\);"; assertTrue( "The command '" + expectedInsertIntoTableGeneratorCommand + "' has not been correctly generated", diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/idgenerator/TableGeneratorsTest.java b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/idgenerator/TableGeneratorsTest.java index 8195b899e6..1ce8aa1b2e 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/idgenerator/TableGeneratorsTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/idgenerator/TableGeneratorsTest.java @@ -72,13 +72,13 @@ public class TableGeneratorsTest extends BaseUnitTestCase { final List commands = Files.readAllLines( output.toPath() ); - final String expectedTestEntityTableCreationCommand = "CREATE TABLE TEST_ENTITY \\(ID .*, PRIMARY KEY \\(ID\\)\\)"; + final String expectedTestEntityTableCreationCommand = "CREATE TABLE TEST_ENTITY \\(ID .*, PRIMARY KEY \\(ID\\)\\);"; assertTrue( "The command '" + expectedTestEntityTableCreationCommand + "' has not been correctly generated", isCommandGenerated( commands, expectedTestEntityTableCreationCommand ) ); - final String expectedIdTableGeneratorCreationCommand = "CREATE TABLE ID_TABLE_GENERATOR \\(PK .*, VALUE .*, PRIMARY KEY \\(PK\\)\\)"; + final String expectedIdTableGeneratorCreationCommand = "CREATE TABLE ID_TABLE_GENERATOR \\(PK .*, VALUE .*, PRIMARY KEY \\(PK\\)\\);"; assertTrue( "The command '" + expectedIdTableGeneratorCreationCommand + "' has not been correctly generated", @@ -89,7 +89,7 @@ public class TableGeneratorsTest extends BaseUnitTestCase { ) ); - final String expectedInsertIntoTableGeneratorCommand = "INSERT INTO ID_TABLE_GENERATOR\\(PK, VALUE\\) VALUES \\('TEST_ENTITY_ID'," + EXPECTED_DB_INSERTED_VALUE + "\\)"; + final String expectedInsertIntoTableGeneratorCommand = "INSERT INTO ID_TABLE_GENERATOR\\(PK, VALUE\\) VALUES \\('TEST_ENTITY_ID'," + EXPECTED_DB_INSERTED_VALUE + "\\);"; assertTrue( "The command '" + expectedInsertIntoTableGeneratorCommand + "' has not been correctly generated", diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/uniqueconstraint/UniqueConstraintGenerationTest.java b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/uniqueconstraint/UniqueConstraintGenerationTest.java index bfecfad11e..ef13a300b1 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/uniqueconstraint/UniqueConstraintGenerationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/uniqueconstraint/UniqueConstraintGenerationTest.java @@ -93,7 +93,7 @@ public class UniqueConstraintGenerationTest { private boolean isUniqueConstraintGenerated(String tableName, String columnName) throws IOException { boolean matches = false; - final String regex = getDialect().getAlterTableString( tableName ) + " add constraint uk_(.)* unique \\(" + columnName + "\\)"; + final String regex = getDialect().getAlterTableString( tableName ) + " add constraint uk_(.)* unique \\(" + columnName + "\\);"; final String fileContent = new String( Files.readAllBytes( output.toPath() ) ).toLowerCase(); final String[] split = fileContent.split( System.lineSeparator() ); @@ -109,7 +109,7 @@ public class UniqueConstraintGenerationTest { private boolean isCreateUniqueIndexGenerated(String tableName, String columnName) throws IOException { boolean matches = false; - String regex = "create unique index uk_(.)* on " + tableName + " \\(" + columnName + "\\)"; + String regex = "create unique index uk_(.)* on " + tableName + " \\(" + columnName + "\\);"; final String fileContent = new String( Files.readAllBytes( output.toPath() ) ).toLowerCase(); final String[] split = fileContent.split( System.lineSeparator() ); diff --git a/hibernate-graalvm/src/main/java/org/hibernate/graalvm/internal/QueryParsingSupport.java b/hibernate-graalvm/src/main/java/org/hibernate/graalvm/internal/QueryParsingSupport.java index cc1c2d77b6..28b1833e77 100644 --- a/hibernate-graalvm/src/main/java/org/hibernate/graalvm/internal/QueryParsingSupport.java +++ b/hibernate-graalvm/src/main/java/org/hibernate/graalvm/internal/QueryParsingSupport.java @@ -11,6 +11,7 @@ import java.lang.reflect.Executable; import java.util.ArrayList; import java.util.concurrent.atomic.AtomicBoolean; +import org.hibernate.internal.build.AllowSysOut; import org.hibernate.internal.util.ReflectHelper; import com.oracle.svm.core.annotate.AutomaticFeature; @@ -50,6 +51,7 @@ public final class QueryParsingSupport implements Feature { access.registerReachabilityHandler(this::enableHQLSupport, parserClazz); } + @AllowSysOut private void enableHQLSupport(DuringAnalysisAccess duringAnalysisAccess) { final boolean needsEnablingYet = triggered.compareAndSet( false, true ); if ( needsEnablingYet ) {