Skip to content

Commit bf5c499

Browse files
committed
HHH-18690 Add internal test methods to SchemaTruncatorImpl
1 parent 810842a commit bf5c499

File tree

1 file changed

+60
-1
lines changed

1 file changed

+60
-1
lines changed

hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaTruncatorImpl.java

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@
44
*/
55
package org.hibernate.tool.schema.internal;
66

7+
import org.hibernate.Internal;
78
import org.hibernate.boot.Metadata;
89
import org.hibernate.boot.model.relational.Database;
910
import org.hibernate.boot.model.relational.Exportable;
1011
import org.hibernate.boot.model.relational.Namespace;
1112
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
1213
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
14+
import org.hibernate.boot.spi.MetadataImplementor;
1315
import org.hibernate.cfg.AvailableSettings;
1416
import org.hibernate.dialect.Dialect;
17+
import org.hibernate.engine.config.spi.ConfigurationService;
18+
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
1519
import org.hibernate.engine.jdbc.internal.FormatStyle;
1620
import org.hibernate.engine.jdbc.internal.Formatter;
1721
import org.hibernate.internal.util.StringHelper;
@@ -25,6 +29,7 @@
2529
import org.hibernate.tool.schema.internal.exec.ScriptSourceInputFromUrl;
2630
import org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl;
2731
import org.hibernate.tool.schema.spi.ContributableMatcher;
32+
import org.hibernate.tool.schema.spi.ExceptionHandler;
2833
import org.hibernate.tool.schema.spi.ExecutionOptions;
2934
import org.hibernate.tool.schema.spi.SchemaFilter;
3035
import org.hibernate.tool.schema.spi.SchemaManagementException;
@@ -81,7 +86,8 @@ public void doTruncate(
8186
doTruncate( metadata, options, contributableInclusionFilter, jdbcContext.getDialect(), targets );
8287
}
8388

84-
private void doTruncate(
89+
@Internal
90+
public void doTruncate(
8591
Metadata metadata,
8692
ExecutionOptions options,
8793
ContributableMatcher contributableInclusionFilter,
@@ -343,4 +349,57 @@ private ScriptSourceInput interpretLegacyImportScriptSetting(
343349
}
344350
}
345351

352+
/**
353+
* Intended for use from tests
354+
*/
355+
@Internal
356+
public void doTruncate(
357+
Metadata metadata,
358+
final boolean manageNamespaces,
359+
GenerationTarget... targets) {
360+
final ServiceRegistry serviceRegistry =
361+
( (MetadataImplementor) metadata ).getMetadataBuildingOptions()
362+
.getServiceRegistry();
363+
doTruncate(
364+
metadata,
365+
serviceRegistry,
366+
serviceRegistry.requireService( ConfigurationService.class ).getSettings(),
367+
manageNamespaces,
368+
targets
369+
);
370+
}
371+
372+
/**
373+
* Intended for use from tests
374+
*/
375+
@Internal
376+
public void doTruncate(
377+
Metadata metadata,
378+
final ServiceRegistry serviceRegistry,
379+
final Map<String,Object> settings,
380+
final boolean manageNamespaces,
381+
GenerationTarget... targets) {
382+
doTruncate(
383+
metadata,
384+
new ExecutionOptions() {
385+
@Override
386+
public boolean shouldManageNamespaces() {
387+
return manageNamespaces;
388+
}
389+
390+
@Override
391+
public Map<String,Object> getConfigurationValues() {
392+
return settings;
393+
}
394+
395+
@Override
396+
public ExceptionHandler getExceptionHandler() {
397+
return ExceptionHandlerLoggedImpl.INSTANCE;
398+
}
399+
},
400+
(contributed) -> true,
401+
serviceRegistry.requireService( JdbcEnvironment.class ).getDialect(),
402+
targets
403+
);
404+
}
346405
}

0 commit comments

Comments
 (0)