HHH-14665 Use semi-colon as the default statement delimiter for scripts
This commit is contained in:
parent
6155f95cf7
commit
10cba26bda
|
@ -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`.
|
||||
|
|
|
@ -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 <code>;</code>.
|
||||
*/
|
||||
String HBM2DDL_DELIMITER = "hibernate.hbm2ddl.delimiter";
|
||||
|
||||
|
|
|
@ -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() ];
|
||||
|
||||
|
|
|
@ -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()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -68,12 +68,12 @@ public class SequenceGenerationTest extends BaseUnitTestCase {
|
|||
List<String> 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 )
|
||||
);
|
||||
}
|
||||
|
|
|
@ -70,12 +70,12 @@ public class SequenceGeneratorsTest extends BaseUnitTestCase {
|
|||
List<String> 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 )
|
||||
);
|
||||
}
|
||||
|
|
|
@ -71,13 +71,13 @@ public class TableGeneratorTest extends BaseUnitTestCase {
|
|||
|
||||
final List<String> 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",
|
||||
|
|
|
@ -72,13 +72,13 @@ public class TableGeneratorsTest extends BaseUnitTestCase {
|
|||
|
||||
final List<String> 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",
|
||||
|
|
|
@ -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() );
|
||||
|
|
|
@ -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 ) {
|
||||
|
|
Loading…
Reference in New Issue