use of org.hibernate.tool.schema.spi.ExecutionOptions in project hibernate-orm by hibernate.
the class UniqueConstraintDropTest method setUp.
@Before
public void setUp() throws Exception {
output = File.createTempFile("update_script", ".sql");
output.deleteOnExit();
ssr = new StandardServiceRegistryBuilder().applySetting(Environment.HBM2DDL_AUTO, "none").applySetting(Environment.FORMAT_SQL, "false").applySetting(Environment.SHOW_SQL, "true").build();
metadata = (MetadataImplementor) new MetadataSources(ssr).addResource("org/hibernate/test/schemaupdate/uniqueconstraint/TestEntity.hbm.xml").buildMetadata();
metadata.validate();
tool = (HibernateSchemaManagementTool) ssr.getService(SchemaManagementTool.class);
final Map configurationValues = ssr.getService(ConfigurationService.class).getSettings();
options = new ExecutionOptions() {
@Override
public boolean shouldManageNamespaces() {
return true;
}
@Override
public Map getConfigurationValues() {
return configurationValues;
}
@Override
public ExceptionHandler getExceptionHandler() {
return ExceptionHandlerLoggedImpl.INSTANCE;
}
};
}
use of org.hibernate.tool.schema.spi.ExecutionOptions 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;
}
};
}
use of org.hibernate.tool.schema.spi.ExecutionOptions 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.spi.ExecutionOptions in project hibernate-orm by hibernate.
the class SchemaCreatorImpl method generateCreationCommands.
/**
* For testing...
*
* @param metadata The metadata for which to generate the creation commands.
*
* @return The generation commands
*/
public List<String> generateCreationCommands(Metadata metadata, final boolean manageNamespaces) {
final JournalingGenerationTarget target = new JournalingGenerationTarget();
final ServiceRegistry serviceRegistry = ((MetadataImplementor) metadata).getMetadataBuildingOptions().getServiceRegistry();
final Dialect dialect = serviceRegistry.getService(JdbcEnvironment.class).getDialect();
final ExecutionOptions options = new ExecutionOptions() {
@Override
public boolean shouldManageNamespaces() {
return manageNamespaces;
}
@Override
public Map getConfigurationValues() {
return Collections.emptyMap();
}
@Override
public ExceptionHandler getExceptionHandler() {
return ExceptionHandlerHaltImpl.INSTANCE;
}
};
createFromMetadata(metadata, options, dialect, FormatStyle.NONE.getFormatter(), target);
return target.commands;
}
use of org.hibernate.tool.schema.spi.ExecutionOptions in project hibernate-orm by hibernate.
the class SchemaDropperImpl method doDrop.
/**
* For tests
*/
public void doDrop(Metadata metadata, final ServiceRegistry serviceRegistry, final Map settings, final boolean manageNamespaces, GenerationTarget... targets) {
if (targets == null || targets.length == 0) {
final JdbcContext jdbcContext = tool.resolveJdbcContext(settings);
targets = new GenerationTarget[] { new GenerationTargetToDatabase(serviceRegistry.getService(TransactionCoordinatorBuilder.class).buildDdlTransactionIsolator(jdbcContext), true) };
}
doDrop(metadata, new ExecutionOptions() {
@Override
public boolean shouldManageNamespaces() {
return manageNamespaces;
}
@Override
public Map getConfigurationValues() {
return settings;
}
@Override
public ExceptionHandler getExceptionHandler() {
return ExceptionHandlerLoggedImpl.INSTANCE;
}
}, serviceRegistry.getService(JdbcEnvironment.class).getDialect(), new SourceDescriptor() {
@Override
public SourceType getSourceType() {
return SourceType.METADATA;
}
@Override
public ScriptSourceInput getScriptSourceInput() {
return null;
}
}, targets);
}
Aggregations