use of org.hibernate.tool.schema.spi.ExceptionHandler in project hibernate-orm by hibernate.
the class IndividuallySchemaValidatorImplTest method setUp.
@Before
public void setUp() throws IOException {
ssr = new StandardServiceRegistryBuilder().build();
tool = (HibernateSchemaManagementTool) ssr.getService(SchemaManagementTool.class);
configurationValues = ssr.getService(ConfigurationService.class).getSettings();
executionOptions = new ExecutionOptions() {
@Override
public boolean shouldManageNamespaces() {
return true;
}
@Override
public Map getConfigurationValues() {
return configurationValues;
}
@Override
public ExceptionHandler getExceptionHandler() {
return ExceptionHandlerLoggedImpl.INSTANCE;
}
@Override
public SchemaFilter getSchemaFilter() {
return SchemaFilter.ALL;
}
};
}
use of org.hibernate.tool.schema.spi.ExceptionHandler in project hibernate-orm by hibernate.
the class SchemaUpdate method execute.
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<String, Object> config = new HashMap<>(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 ExceptionHandler exceptionHandler = haltOnError ? ExceptionHandlerHaltImpl.INSTANCE : new ExceptionHandlerCollectingImpl();
final ExecutionOptions executionOptions = SchemaManagementToolCoordinator.buildExecutionOptions(config, exceptionHandler);
final TargetDescriptor targetDescriptor = SchemaExport.buildTargetDescriptor(targetTypes, outputFile, append, serviceRegistry);
try {
tool.getSchemaMigrator(config).doMigration(metadata, executionOptions, ContributableMatcher.ALL, targetDescriptor);
} finally {
if (exceptionHandler instanceof ExceptionHandlerCollectingImpl) {
exceptions.addAll(((ExceptionHandlerCollectingImpl) exceptionHandler).getExceptions());
}
}
}
Aggregations