|
4 | 4 | */
|
5 | 5 | package org.hibernate.tool.schema.internal;
|
6 | 6 |
|
| 7 | +import org.hibernate.Internal; |
7 | 8 | import org.hibernate.boot.Metadata;
|
8 | 9 | import org.hibernate.boot.model.relational.Database;
|
9 | 10 | import org.hibernate.boot.model.relational.Exportable;
|
10 | 11 | import org.hibernate.boot.model.relational.Namespace;
|
11 | 12 | import org.hibernate.boot.model.relational.SqlStringGenerationContext;
|
12 | 13 | import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
| 14 | +import org.hibernate.boot.spi.MetadataImplementor; |
13 | 15 | import org.hibernate.cfg.AvailableSettings;
|
14 | 16 | import org.hibernate.dialect.Dialect;
|
| 17 | +import org.hibernate.engine.config.spi.ConfigurationService; |
| 18 | +import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment; |
15 | 19 | import org.hibernate.engine.jdbc.internal.FormatStyle;
|
16 | 20 | import org.hibernate.engine.jdbc.internal.Formatter;
|
17 | 21 | import org.hibernate.internal.util.StringHelper;
|
|
25 | 29 | import org.hibernate.tool.schema.internal.exec.ScriptSourceInputFromUrl;
|
26 | 30 | import org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl;
|
27 | 31 | import org.hibernate.tool.schema.spi.ContributableMatcher;
|
| 32 | +import org.hibernate.tool.schema.spi.ExceptionHandler; |
28 | 33 | import org.hibernate.tool.schema.spi.ExecutionOptions;
|
29 | 34 | import org.hibernate.tool.schema.spi.SchemaFilter;
|
30 | 35 | import org.hibernate.tool.schema.spi.SchemaManagementException;
|
@@ -81,7 +86,8 @@ public void doTruncate(
|
81 | 86 | doTruncate( metadata, options, contributableInclusionFilter, jdbcContext.getDialect(), targets );
|
82 | 87 | }
|
83 | 88 |
|
84 |
| - private void doTruncate( |
| 89 | + @Internal |
| 90 | + public void doTruncate( |
85 | 91 | Metadata metadata,
|
86 | 92 | ExecutionOptions options,
|
87 | 93 | ContributableMatcher contributableInclusionFilter,
|
@@ -343,4 +349,57 @@ private ScriptSourceInput interpretLegacyImportScriptSetting(
|
343 | 349 | }
|
344 | 350 | }
|
345 | 351 |
|
| 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 | + } |
346 | 405 | }
|
0 commit comments