Search in sources :

Example 1 with SequenceDefinition

use of org.jooq.util.SequenceDefinition in project jOOQ by jOOQ.

the class PostgresDatabase 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, SEQUENCES.NUMERIC_PRECISION, SEQUENCES.NUMERIC_SCALE).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), 0, record.get(SEQUENCES.NUMERIC_PRECISION), record.get(SEQUENCES.NUMERIC_SCALE), false, (String) null);
        result.add(new DefaultSequenceDefinition(schema, record.get(SEQUENCES.SEQUENCE_NAME), type));
    }
    return result;
}
Also used : DefaultSequenceDefinition(org.jooq.util.DefaultSequenceDefinition) SchemaDefinition(org.jooq.util.SchemaDefinition) SequenceDefinition(org.jooq.util.SequenceDefinition) DefaultSequenceDefinition(org.jooq.util.DefaultSequenceDefinition) DefaultDataTypeDefinition(org.jooq.util.DefaultDataTypeDefinition) ArrayList(java.util.ArrayList) Record(org.jooq.Record) DefaultDataTypeDefinition(org.jooq.util.DefaultDataTypeDefinition) DataTypeDefinition(org.jooq.util.DataTypeDefinition)

Example 2 with SequenceDefinition

use of org.jooq.util.SequenceDefinition in project jOOQ by jOOQ.

the class JDBCDatabase method getSequences0.

@Override
protected List<SequenceDefinition> getSequences0() throws SQLException {
    List<SequenceDefinition> result = new ArrayList<SequenceDefinition>();
    for (Schema schema : getSchemasFromMeta()) {
        for (Sequence<?> sequence : schema.getSequences()) {
            SchemaDefinition sd = getSchema(schema.getName());
            DataTypeDefinition type = new DefaultDataTypeDefinition(this, sd, sequence.getDataType().getTypeName());
            result.add(new DefaultSequenceDefinition(sd, sequence.getName(), type));
        }
    }
    return result;
}
Also used : DefaultSequenceDefinition(org.jooq.util.DefaultSequenceDefinition) SchemaDefinition(org.jooq.util.SchemaDefinition) DefaultSequenceDefinition(org.jooq.util.DefaultSequenceDefinition) SequenceDefinition(org.jooq.util.SequenceDefinition) DefaultDataTypeDefinition(org.jooq.util.DefaultDataTypeDefinition) Schema(org.jooq.Schema) ArrayList(java.util.ArrayList) DefaultDataTypeDefinition(org.jooq.util.DefaultDataTypeDefinition) DataTypeDefinition(org.jooq.util.DataTypeDefinition)

Example 3 with SequenceDefinition

use of org.jooq.util.SequenceDefinition in project jOOQ by jOOQ.

the class XMLDatabase method getSequences0.

@Override
protected List<SequenceDefinition> getSequences0() {
    List<SequenceDefinition> result = new ArrayList<SequenceDefinition>();
    for (Sequence sequence : info().getSequences()) {
        if (getInputSchemata().contains(sequence.getSequenceSchema())) {
            SchemaDefinition schema = getSchema(sequence.getSequenceSchema());
            DataTypeDefinition type = new DefaultDataTypeDefinition(this, schema, sequence.getDataType(), sequence.getCharacterMaximumLength(), sequence.getNumericPrecision(), sequence.getNumericScale(), false, (String) null);
            result.add(new DefaultSequenceDefinition(schema, sequence.getSequenceName(), type));
        }
    }
    return result;
}
Also used : DefaultSequenceDefinition(org.jooq.util.DefaultSequenceDefinition) SchemaDefinition(org.jooq.util.SchemaDefinition) SequenceDefinition(org.jooq.util.SequenceDefinition) DefaultSequenceDefinition(org.jooq.util.DefaultSequenceDefinition) DefaultDataTypeDefinition(org.jooq.util.DefaultDataTypeDefinition) ArrayList(java.util.ArrayList) Sequence(org.jooq.util.xml.jaxb.Sequence) DefaultDataTypeDefinition(org.jooq.util.DefaultDataTypeDefinition) DataTypeDefinition(org.jooq.util.DataTypeDefinition)

Example 4 with SequenceDefinition

use of org.jooq.util.SequenceDefinition in project jOOQ by jOOQ.

the class CUBRIDDatabase method getSequences0.

@Override
protected List<SequenceDefinition> getSequences0() throws SQLException {
    List<SequenceDefinition> result = new ArrayList<SequenceDefinition>();
    for (Record record : create().select(DB_SERIAL.NAME, DB_SERIAL.MAX_VAL).from(DB_SERIAL).fetch()) {
        BigInteger value = defaultIfNull(record.get(DB_SERIAL.MAX_VAL, BigInteger.class), BigInteger.valueOf(Long.MAX_VALUE));
        DataTypeDefinition type = getDataTypeForMAX_VAL(getSchemata().get(0), value);
        result.add(new DefaultSequenceDefinition(getSchemata().get(0), record.get(DB_SERIAL.NAME), type));
    }
    return result;
}
Also used : DefaultSequenceDefinition(org.jooq.util.DefaultSequenceDefinition) DefaultSequenceDefinition(org.jooq.util.DefaultSequenceDefinition) SequenceDefinition(org.jooq.util.SequenceDefinition) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) Record(org.jooq.Record) DataTypeDefinition(org.jooq.util.DataTypeDefinition)

Example 5 with SequenceDefinition

use of org.jooq.util.SequenceDefinition in project jOOQ by jOOQ.

the class DerbyDatabase method getSequences0.

@Override
protected List<SequenceDefinition> getSequences0() throws SQLException {
    List<SequenceDefinition> result = new ArrayList<SequenceDefinition>();
    for (Record record : create().select(Sysschemas.SCHEMANAME, Syssequences.SEQUENCENAME, Syssequences.SEQUENCEDATATYPE).from(SYSSEQUENCES).join(SYSSCHEMAS).on(Sysschemas.SCHEMAID.equal(Syssequences.SCHEMAID)).where(Sysschemas.SCHEMANAME.in(getInputSchemata())).orderBy(Sysschemas.SCHEMANAME, Syssequences.SEQUENCENAME).fetch()) {
        SchemaDefinition schema = getSchema(record.get(Sysschemas.SCHEMANAME));
        DataTypeDefinition type = new DefaultDataTypeDefinition(this, schema, record.get(Syssequences.SEQUENCEDATATYPE));
        result.add(new DefaultSequenceDefinition(schema, record.get(Syssequences.SEQUENCENAME, String.class), type));
    }
    return result;
}
Also used : DefaultSequenceDefinition(org.jooq.util.DefaultSequenceDefinition) SchemaDefinition(org.jooq.util.SchemaDefinition) DefaultSequenceDefinition(org.jooq.util.DefaultSequenceDefinition) SequenceDefinition(org.jooq.util.SequenceDefinition) DefaultDataTypeDefinition(org.jooq.util.DefaultDataTypeDefinition) ArrayList(java.util.ArrayList) Record(org.jooq.Record) DefaultDataTypeDefinition(org.jooq.util.DefaultDataTypeDefinition) DataTypeDefinition(org.jooq.util.DataTypeDefinition)

Aggregations

ArrayList (java.util.ArrayList)8 DefaultSequenceDefinition (org.jooq.util.DefaultSequenceDefinition)8 SequenceDefinition (org.jooq.util.SequenceDefinition)8 DataTypeDefinition (org.jooq.util.DataTypeDefinition)7 DefaultDataTypeDefinition (org.jooq.util.DefaultDataTypeDefinition)7 SchemaDefinition (org.jooq.util.SchemaDefinition)7 Record (org.jooq.Record)5 BigInteger (java.math.BigInteger)1 Schema (org.jooq.Schema)1 Sequence (org.jooq.util.xml.jaxb.Sequence)1