1313import org .hibernate .dialect .Dialect ;
1414import org .hibernate .engine .jdbc .internal .FormatStyle ;
1515import org .hibernate .engine .jdbc .internal .Formatter ;
16- import org .hibernate .internal .util .collections .CollectionHelper ;
1716import org .hibernate .mapping .Table ;
1817import org .hibernate .tool .schema .spi .GenerationTarget ;
1918import org .hibernate .tool .schema .spi .ContributableMatcher ;
2928import java .util .List ;
3029import java .util .Set ;
3130
31+ import static org .hibernate .internal .util .collections .CollectionHelper .setOfSize ;
3232import static org .hibernate .tool .schema .internal .Helper .applySqlString ;
3333import static org .hibernate .tool .schema .internal .Helper .applySqlStrings ;
3434import static org .hibernate .tool .schema .internal .Helper .createSqlStringGenerationContext ;
@@ -110,9 +110,9 @@ private void truncateFromMetadata(
110110 Formatter formatter ,
111111 GenerationTarget ... targets ) {
112112 final var database = metadata .getDatabase ();
113- SqlStringGenerationContext context = createSqlStringGenerationContext ( options , metadata );
113+ final var context = createSqlStringGenerationContext ( options , metadata );
114114
115- final Set <String > exportIdentifiers = CollectionHelper . setOfSize ( 50 );
115+ final Set <String > exportIdentifiers = setOfSize ( 50 );
116116
117117 for ( var namespace : database .getNamespaces () ) {
118118 if ( schemaFilter .includeNamespace ( namespace ) ) {
@@ -121,19 +121,14 @@ private void truncateFromMetadata(
121121 applySqlString ( dialect .getTableCleaner ().getSqlBeforeString (), formatter , options , targets );
122122
123123 // now it's safe to drop the tables
124- List <Table > list = new ArrayList <>( namespace .getTables ().size () );
125- for ( Table table : namespace .getTables () ) {
126- if ( !table .isPhysicalTable () ) {
127- continue ;
124+ final List <Table > list = new ArrayList <>( namespace .getTables ().size () );
125+ for ( var table : namespace .getTables () ) {
126+ if ( table .isPhysicalTable ()
127+ && schemaFilter .includeTable ( table )
128+ && contributableInclusionFilter .matches ( table ) ) {
129+ checkExportIdentifier ( table , exportIdentifiers );
130+ list .add ( table );
128131 }
129- if ( !schemaFilter .includeTable ( table ) ) {
130- continue ;
131- }
132- if ( !contributableInclusionFilter .matches ( table ) ) {
133- continue ;
134- }
135- checkExportIdentifier ( table , exportIdentifiers );
136- list .add ( table );
137132 }
138133 applySqlStrings (
139134 dialect .getTableCleaner ().getSqlTruncateStrings ( list , metadata , context ),
@@ -175,7 +170,6 @@ private void disableConstraints(
175170 ContributableMatcher contributableInclusionFilter ,
176171 GenerationTarget ... targets ) {
177172 final var dialect = metadata .getDatabase ().getJdbcEnvironment ().getDialect ();
178-
179173 for ( var table : namespace .getTables () ) {
180174 if ( table .isPhysicalTable ()
181175 && schemaFilter .includeTable ( table )
@@ -213,8 +207,8 @@ private void enableConstraints(
213207 SqlStringGenerationContext context ,
214208 ContributableMatcher contributableInclusionFilter ,
215209 GenerationTarget ... targets ) {
216- final Dialect dialect = metadata .getDatabase ().getJdbcEnvironment ().getDialect ();
217- for ( Table table : namespace .getTables () ) {
210+ final var dialect = metadata .getDatabase ().getJdbcEnvironment ().getDialect ();
211+ for ( var table : namespace .getTables () ) {
218212 if ( table .isPhysicalTable ()
219213 && schemaFilter .includeTable ( table )
220214 && contributableInclusionFilter .matches ( table ) ) {
0 commit comments