use of org.jooq.TableOptions.OnCommit in project jOOQ by jOOQ.
the class DDL method createTableOrView.
final List<Query> createTableOrView(Table<?> table, Collection<? extends Constraint> constraints) {
boolean temporary = table.getTableType() == TableType.TEMPORARY;
boolean view = table.getTableType().isView();
OnCommit onCommit = table.getOptions().onCommit();
if (view) {
List<Query> result = new ArrayList<>();
result.add(applyAs((configuration.createViewIfNotExists() ? ctx.createViewIfNotExists(table, table.fields()) : configuration.createOrReplaceView() ? ctx.createOrReplaceView(table, table.fields()) : ctx.createView(table, table.fields())), table.getOptions()));
if (!constraints.isEmpty() && configuration.includeConstraintsOnViews())
result.addAll(alterTableAddConstraints(table));
return result;
}
CreateTableOnCommitStep s0 = (configuration.createTableIfNotExists() ? temporary ? ctx.createTemporaryTableIfNotExists(table) : ctx.createTableIfNotExists(table) : temporary ? ctx.createTemporaryTable(table) : ctx.createTable(table)).columns(sortIf(asList(table.fields()), !configuration.respectColumnOrder())).constraints(constraints);
if (temporary && onCommit != null) {
switch(onCommit) {
case DELETE_ROWS:
return asList(s0.onCommitDeleteRows());
case PRESERVE_ROWS:
return asList(s0.onCommitPreserveRows());
case DROP:
return asList(s0.onCommitDrop());
default:
throw new IllegalStateException("Unsupported flag: " + onCommit);
}
}
return asList(s0);
}
Aggregations