diff --git a/documentation/src/main/asciidoc/userguide/appendices/Configurations.adoc b/documentation/src/main/asciidoc/userguide/appendices/Configurations.adoc index c1580c19eb..77e117abde 100644 --- a/documentation/src/main/asciidoc/userguide/appendices/Configurations.adoc +++ b/documentation/src/main/asciidoc/userguide/appendices/Configurations.adoc @@ -607,7 +607,8 @@ Used to specify the `org.hibernate.tool.schema.spi.SchemaFilterProvider` to be u Setting to choose the strategy used to access the JDBC Metadata. Valid options are defined by the `strategy` value of the `org.hibernate.tool.schema.JdbcMetadaAccessStrategy` enum: -`grouped`:: `org.hibernate.tool.schema.spi.SchemaMigrator` and `org.hibernate.tool.schema.spi.SchemaValidator` execute a single `java.sql.DatabaseMetaData#getTables(String, String, String, String[])` call to retrieve all the database table in order to determine if all the `javax.persistence.Entity` have a corresponding mapped database tables. +`grouped`:: `org.hibernate.tool.schema.spi.SchemaMigrator` and `org.hibernate.tool.schema.spi.SchemaValidator` execute a single `java.sql.DatabaseMetaData#getTables(String, String, String, String[])` call to retrieve all the database table in order to determine if all the `javax.persistence.Entity` have a corresponding mapped database tables. This strategy may require `hibernate.default_schema` and/or `hibernate.default_catalog` to be provided. + `individually`:: `org.hibernate.tool.schema.spi.SchemaMigrator` and `org.hibernate.tool.schema.spi.SchemaValidator` execute one `java.sql.DatabaseMetaData#getTables(String, String, String, String[])` call for each `javax.persistence.Entity` in order to determine if a corresponding database table exists. |`hibernate.hbm2ddl.delimiter` | `;` |Identifies the delimiter to use to separate schema management statements in script outputs. 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 010668d352..3d2dff72de 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java @@ -1087,6 +1087,8 @@ public interface AvailableSettings { * * Valid options are defined by the {@link JdbcMetadaAccessStrategy} enum. * + * {@link JdbcMetadaAccessStrategy#GROUPED} is the default value. + * * @see JdbcMetadaAccessStrategy */ String HBM2DDL_JDBC_METADATA_EXTRACTOR_STRATEGY = "hibernate.hbm2ddl.jdbc_metadata_extraction_strategy"; diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/JdbcMetadaAccessStrategy.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/JdbcMetadaAccessStrategy.java index 6ce5049d9a..4bc1b624c4 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/JdbcMetadaAccessStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/JdbcMetadaAccessStrategy.java @@ -24,6 +24,9 @@ public enum JdbcMetadaAccessStrategy { * The {@link org.hibernate.tool.schema.spi.SchemaMigrator} and {@link org.hibernate.tool.schema.spi.SchemaValidator} * execute a single {@link java.sql.DatabaseMetaData#getTables(String, String, String, String[])} call * to retrieve all the database table in order to determine all the {@link javax.persistence.Entity} have a mapped database tables. + * + * This strategy is the default one and it may require {@link AvailableSettings#DEFAULT_CATALOG} and/or + * {@link AvailableSettings#DEFAULT_SCHEMA} values to be provided. */ GROUPED( "grouped" ); diff --git a/migration-guide.adoc b/migration-guide.adoc index a80494f25c..3c8060e565 100644 --- a/migration-guide.adoc +++ b/migration-guide.adoc @@ -32,3 +32,12 @@ These changes will only be a migration concern for applications directly using a * `org.hibernate.tool.hbm2ddl.SchemaValidator` * `org.hibernate.tool.schema.spi.SchemaManagementTool` or any of its delegates + +In 5.1.4, a new strategy for retrieving database tables was introduced that improves SchemaMigrator and SchemaValidator +performance. This strategy executes a single `java.sql.DatabaseMetaData#getTables(String, String, String, String[])` +call to determine if each `javax.persistence.Entity` has a mapped database table. +This strategy is the default, and uses the property setting `hibernate.hbm2ddl.jdbc_metadata_extraction_strategy=grouped`. +This strategy may require `hibernate.default_schema` and/or `hibernate.default_catalog` to be provided. + +To use the old strategy, which executes a `java.sql.DatabaseMetaData#getTables(String, String, String, String[])` call for +each javax.persistence.Entity, use the property setting `hibernate.hbm2ddl.jdbc_metadata_extraction_strategy=individually`.