use of org.hibernate.tool.schema.internal.ExceptionHandlerCollectingImpl in project hibernate-orm by hibernate.
the class SchemaExport method doExecution.
public void doExecution(Action action, boolean needsJdbc, Metadata metadata, ServiceRegistry serviceRegistry, TargetDescriptor targetDescriptor) {
Map config = new HashMap();
config.putAll(serviceRegistry.getService(ConfigurationService.class).getSettings());
config.put(AvailableSettings.HBM2DDL_DELIMITER, delimiter);
config.put(AvailableSettings.FORMAT_SQL, format);
config.put(AvailableSettings.HBM2DDL_IMPORT_FILES, importFiles);
final SchemaManagementTool tool = serviceRegistry.getService(SchemaManagementTool.class);
final ExceptionHandler exceptionHandler = haltOnError ? ExceptionHandlerHaltImpl.INSTANCE : new ExceptionHandlerCollectingImpl();
final ExecutionOptions executionOptions = SchemaManagementToolCoordinator.buildExecutionOptions(config, exceptionHandler);
final SourceDescriptor sourceDescriptor = new SourceDescriptor() {
@Override
public SourceType getSourceType() {
return SourceType.METADATA;
}
@Override
public ScriptSourceInput getScriptSourceInput() {
return null;
}
};
try {
if (action.doDrop()) {
tool.getSchemaDropper(config).doDrop(metadata, executionOptions, sourceDescriptor, targetDescriptor);
}
if (action.doCreate()) {
tool.getSchemaCreator(config).doCreation(metadata, executionOptions, sourceDescriptor, targetDescriptor);
}
} finally {
if (exceptionHandler instanceof ExceptionHandlerCollectingImpl) {
exceptions.addAll(((ExceptionHandlerCollectingImpl) exceptionHandler).getExceptions());
}
}
}
use of org.hibernate.tool.schema.internal.ExceptionHandlerCollectingImpl in project hibernate-orm by hibernate.
the class SchemaUpdate method execute.
@SuppressWarnings("unchecked")
public void execute(EnumSet<TargetType> targetTypes, Metadata metadata, ServiceRegistry serviceRegistry) {
if (targetTypes.isEmpty()) {
LOG.debug("Skipping SchemaExport as no targets were specified");
return;
}
exceptions.clear();
LOG.runningHbm2ddlSchemaUpdate();
Map config = new HashMap();
config.putAll(serviceRegistry.getService(ConfigurationService.class).getSettings());
config.put(AvailableSettings.HBM2DDL_DELIMITER, delimiter);
config.put(AvailableSettings.FORMAT_SQL, format);
final SchemaManagementTool tool = serviceRegistry.getService(SchemaManagementTool.class);
final ExceptionHandlerCollectingImpl exceptionHandler = new ExceptionHandlerCollectingImpl();
final ExecutionOptions executionOptions = SchemaManagementToolCoordinator.buildExecutionOptions(config, exceptionHandler);
final TargetDescriptor targetDescriptor = SchemaExport.buildTargetDescriptor(targetTypes, outputFile, serviceRegistry);
try {
tool.getSchemaMigrator(config).doMigration(metadata, executionOptions, targetDescriptor);
} finally {
exceptions.addAll(exceptionHandler.getExceptions());
}
}
Aggregations