use of org.jooq.util.SchemaDefinition in project jOOQ by jOOQ.
the class FirebirdDatabase method getSequences0.
@Override
protected List<SequenceDefinition> getSequences0() throws SQLException {
List<SequenceDefinition> result = new ArrayList<SequenceDefinition>();
for (String sequenceName : create().select(RDB$GENERATORS.RDB$GENERATOR_NAME.trim()).from(RDB$GENERATORS).orderBy(1).fetch(RDB$GENERATORS.RDB$GENERATOR_NAME.trim())) {
SchemaDefinition schema = getSchemata().get(0);
DataTypeDefinition type = new DefaultDataTypeDefinition(this, schema, FirebirdDataType.BIGINT.getTypeName());
result.add(new DefaultSequenceDefinition(schema, sequenceName, type));
}
return result;
}
use of org.jooq.util.SchemaDefinition in project jOOQ by jOOQ.
the class H2Database method getSequences0.
@Override
protected List<SequenceDefinition> getSequences0() throws SQLException {
List<SequenceDefinition> result = new ArrayList<SequenceDefinition>();
for (Record record : create().select(Sequences.SEQUENCE_SCHEMA, Sequences.SEQUENCE_NAME).from(SEQUENCES).where(Sequences.SEQUENCE_SCHEMA.in(getInputSchemata())).orderBy(Sequences.SEQUENCE_SCHEMA, Sequences.SEQUENCE_NAME).fetch()) {
SchemaDefinition schema = getSchema(record.get(Sequences.SEQUENCE_SCHEMA));
if (schema != null) {
String name = record.get(Sequences.SEQUENCE_NAME);
DefaultDataTypeDefinition type = new DefaultDataTypeDefinition(this, schema, H2DataType.BIGINT.getTypeName());
result.add(new DefaultSequenceDefinition(schema, name, type));
}
}
return result;
}
use of org.jooq.util.SchemaDefinition in project jOOQ by jOOQ.
the class H2Database method loadForeignKeys.
@Override
protected void loadForeignKeys(DefaultRelations relations) throws SQLException {
for (Record record : create().select(CrossReferences.FK_NAME, CrossReferences.FKTABLE_NAME, CrossReferences.FKTABLE_SCHEMA, CrossReferences.FKCOLUMN_NAME, Constraints.CONSTRAINT_NAME, Constraints.CONSTRAINT_SCHEMA).from(CROSS_REFERENCES).join(CONSTRAINTS).on(CrossReferences.PK_NAME.equal(Constraints.UNIQUE_INDEX_NAME)).and(CrossReferences.PKTABLE_NAME.equal(Constraints.TABLE_NAME)).and(CrossReferences.PKTABLE_SCHEMA.equal(Constraints.TABLE_SCHEMA)).where(CrossReferences.FKTABLE_SCHEMA.in(getInputSchemata())).and(Constraints.CONSTRAINT_TYPE.in("PRIMARY KEY", "UNIQUE")).orderBy(CrossReferences.FKTABLE_SCHEMA.asc(), CrossReferences.FK_NAME.asc(), CrossReferences.ORDINAL_POSITION.asc()).fetch()) {
SchemaDefinition foreignKeySchema = getSchema(record.get(CrossReferences.FKTABLE_SCHEMA));
SchemaDefinition uniqueKeySchema = getSchema(record.get(Constraints.CONSTRAINT_SCHEMA));
if (foreignKeySchema != null && uniqueKeySchema != null) {
String foreignKeyTableName = record.get(CrossReferences.FKTABLE_NAME);
String foreignKeyColumn = record.get(CrossReferences.FKCOLUMN_NAME);
String foreignKey = record.get(CrossReferences.FK_NAME);
String uniqueKey = record.get(Constraints.CONSTRAINT_NAME);
TableDefinition foreignKeyTable = getTable(foreignKeySchema, foreignKeyTableName);
if (foreignKeyTable != null) {
ColumnDefinition referencingColumn = foreignKeyTable.getColumn(foreignKeyColumn);
relations.addForeignKey(foreignKey, uniqueKey, referencingColumn, uniqueKeySchema);
}
}
}
}
use of org.jooq.util.SchemaDefinition in project jOOQ by jOOQ.
the class H2Database method loadPrimaryKeys.
@Override
protected void loadPrimaryKeys(DefaultRelations relations) throws SQLException {
for (Record record : fetchKeys("PRIMARY KEY")) {
SchemaDefinition schema = getSchema(record.get(Constraints.TABLE_SCHEMA));
if (schema != null) {
String tableName = record.get(Constraints.TABLE_NAME);
String primaryKey = record.get(Constraints.CONSTRAINT_NAME);
String columnName = record.get(Indexes.COLUMN_NAME);
TableDefinition table = getTable(schema, tableName);
if (table != null) {
relations.addPrimaryKey(primaryKey, table.getColumn(columnName));
}
}
}
}
use of org.jooq.util.SchemaDefinition in project jOOQ by jOOQ.
the class HSQLDBDatabase method getSequences0.
@Override
protected List<SequenceDefinition> getSequences0() throws SQLException {
List<SequenceDefinition> result = new ArrayList<SequenceDefinition>();
for (Record record : create().select(SEQUENCES.SEQUENCE_SCHEMA, SEQUENCES.SEQUENCE_NAME, SEQUENCES.DATA_TYPE).from(SEQUENCES).where(SEQUENCES.SEQUENCE_SCHEMA.in(getInputSchemata())).orderBy(SEQUENCES.SEQUENCE_SCHEMA, SEQUENCES.SEQUENCE_NAME).fetch()) {
SchemaDefinition schema = getSchema(record.get(SEQUENCES.SEQUENCE_SCHEMA));
DataTypeDefinition type = new DefaultDataTypeDefinition(this, schema, record.get(SEQUENCES.DATA_TYPE));
result.add(new DefaultSequenceDefinition(schema, record.get(SEQUENCES.SEQUENCE_NAME), type));
}
return result;
}
Aggregations