use of org.hibernate.tool.schema.internal.exec.GenerationTargetToStdout in project hibernate-orm by hibernate.
the class HibernateSchemaManagementTool method buildGenerationTargets.
GenerationTarget[] buildGenerationTargets(TargetDescriptor targetDescriptor, DdlTransactionIsolator ddlTransactionIsolator, Map options) {
final String scriptDelimiter = ConfigurationHelper.getString(HBM2DDL_DELIMITER, options);
final GenerationTarget[] targets = new GenerationTarget[targetDescriptor.getTargetTypes().size()];
int index = 0;
if (targetDescriptor.getTargetTypes().contains(TargetType.STDOUT)) {
targets[index] = new GenerationTargetToStdout(scriptDelimiter);
index++;
}
if (targetDescriptor.getTargetTypes().contains(TargetType.SCRIPT)) {
if (targetDescriptor.getScriptTargetOutput() == null) {
throw new SchemaManagementException("Writing to script was requested, but no script file was specified");
}
targets[index] = new GenerationTargetToScript(targetDescriptor.getScriptTargetOutput(), scriptDelimiter);
index++;
}
if (targetDescriptor.getTargetTypes().contains(TargetType.DATABASE)) {
targets[index] = new GenerationTargetToDatabase(ddlTransactionIsolator, false);
}
return targets;
}
use of org.hibernate.tool.schema.internal.exec.GenerationTargetToStdout in project hibernate-orm by hibernate.
the class HibernateSchemaManagementTool method buildGenerationTargets.
GenerationTarget[] buildGenerationTargets(TargetDescriptor targetDescriptor, JdbcContext jdbcContext, Map options, boolean needsAutoCommit) {
final String scriptDelimiter = ConfigurationHelper.getString(HBM2DDL_DELIMITER, options);
final GenerationTarget[] targets = new GenerationTarget[targetDescriptor.getTargetTypes().size()];
int index = 0;
if (targetDescriptor.getTargetTypes().contains(TargetType.STDOUT)) {
targets[index] = new GenerationTargetToStdout(scriptDelimiter);
index++;
}
if (targetDescriptor.getTargetTypes().contains(TargetType.SCRIPT)) {
if (targetDescriptor.getScriptTargetOutput() == null) {
throw new SchemaManagementException("Writing to script was requested, but no script file was specified");
}
targets[index] = new GenerationTargetToScript(targetDescriptor.getScriptTargetOutput(), scriptDelimiter);
index++;
}
if (targetDescriptor.getTargetTypes().contains(TargetType.DATABASE)) {
targets[index] = new GenerationTargetToDatabase(getDdlTransactionIsolator(jdbcContext), true);
}
return targets;
}
use of org.hibernate.tool.schema.internal.exec.GenerationTargetToStdout in project hibernate-orm by hibernate.
the class ListMappingTest method testOrderColumnInNormalBiDirectonalModel.
@Test
public void testOrderColumnInNormalBiDirectonalModel() {
Metadata metadata = new MetadataSources(ssr).addAnnotatedClass(Order.class).addAnnotatedClass(LineItem.class).buildMetadata();
Collection lineItemsBinding = metadata.getCollectionBindings().iterator().next();
// make sure it was interpreted as a List (aka, as having an OrderColumn at all)
assertThat(lineItemsBinding, instanceOf(org.hibernate.mapping.List.class));
org.hibernate.mapping.List asList = (org.hibernate.mapping.List) lineItemsBinding;
// assert the OrderColumn details
final Column positionColumn = (Column) asList.getIndex().getColumnIterator().next();
assertThat(positionColumn.getName(), equalTo("position"));
// make sure the OrderColumn is part of the collection table
assertTrue(asList.getCollectionTable().containsColumn(positionColumn));
class TargetImpl extends GenerationTargetToStdout {
boolean found = false;
@Override
public void accept(String action) {
super.accept(action);
if (action.startsWith("create table t_line_item")) {
if (action.contains("position")) {
found = true;
}
}
}
}
TargetImpl target = new TargetImpl();
new SchemaCreatorImpl(ssr).doCreation(metadata, true, target);
assertTrue(target.found);
}
Aggregations