Search in sources :

Example 1 with DefaultSequenceDefinition

use of org.jooq.meta.DefaultSequenceDefinition in project jOOQ by jOOQ.

the class H2Database method getSequences0.

@Override
protected List<SequenceDefinition> getSequences0() throws SQLException {
    List<SequenceDefinition> result = new ArrayList<>();
    for (Record record : sequences(getInputSchemata())) {
        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, null, // H2 doesn't support Postgres-style START WITH
            null, record.get(SEQUENCES.INCREMENT), record.get(SEQUENCES.MIN_VALUE), record.get(SEQUENCES.MAX_VALUE), record.get(SEQUENCES.IS_CYCLE), record.get(SEQUENCES.CACHE)));
        }
    }
    return result;
}
Also used : DefaultSequenceDefinition(org.jooq.meta.DefaultSequenceDefinition) SchemaDefinition(org.jooq.meta.SchemaDefinition) DefaultSequenceDefinition(org.jooq.meta.DefaultSequenceDefinition) SequenceDefinition(org.jooq.meta.SequenceDefinition) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition) ArrayList(java.util.ArrayList) Record(org.jooq.Record)

Example 2 with DefaultSequenceDefinition

use of org.jooq.meta.DefaultSequenceDefinition in project jOOQ by jOOQ.

the class HSQLDBDatabase method getSequences0.

@Override
protected List<SequenceDefinition> getSequences0() throws SQLException {
    List<SequenceDefinition> result = new ArrayList<>();
    for (Record record : sequences(getInputSchemata())) {
        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;
}
Also used : DefaultSequenceDefinition(org.jooq.meta.DefaultSequenceDefinition) SchemaDefinition(org.jooq.meta.SchemaDefinition) DefaultSequenceDefinition(org.jooq.meta.DefaultSequenceDefinition) SequenceDefinition(org.jooq.meta.SequenceDefinition) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition) ArrayList(java.util.ArrayList) Record(org.jooq.Record) DataTypeDefinition(org.jooq.meta.DataTypeDefinition) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition)

Example 3 with DefaultSequenceDefinition

use of org.jooq.meta.DefaultSequenceDefinition in project jOOQ by jOOQ.

the class PostgresDatabase method getSequences0.

@Override
protected List<SequenceDefinition> getSequences0() throws SQLException {
    List<SequenceDefinition> result = new ArrayList<>();
    for (Record record : sequences(getInputSchemata())) {
        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, null, record.get(SEQUENCES.START_VALUE, BigInteger.class), record.get(SEQUENCES.INCREMENT, BigInteger.class), record.get(SEQUENCES.MINIMUM_VALUE, BigInteger.class), record.get(SEQUENCES.MAXIMUM_VALUE, BigInteger.class), record.get(SEQUENCES.CYCLE_OPTION, Boolean.class), // [#9442] The CACHE flag is not available from SEQUENCES
        null));
    }
    return result;
}
Also used : DefaultSequenceDefinition(org.jooq.meta.DefaultSequenceDefinition) SchemaDefinition(org.jooq.meta.SchemaDefinition) DefaultSequenceDefinition(org.jooq.meta.DefaultSequenceDefinition) SequenceDefinition(org.jooq.meta.SequenceDefinition) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition) ArrayList(java.util.ArrayList) Record(org.jooq.Record) DataTypeDefinition(org.jooq.meta.DataTypeDefinition) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition)

Example 4 with DefaultSequenceDefinition

use of org.jooq.meta.DefaultSequenceDefinition in project jOOQ by jOOQ.

the class DerbyDatabase method getSequences0.

@Override
protected List<SequenceDefinition> getSequences0() throws SQLException {
    List<SequenceDefinition> result = new ArrayList<>();
    for (Record record : sequences(getInputSchemata())) {
        SchemaDefinition schema = getSchema(record.get(SYSSEQUENCES.sysschemas().SCHEMANAME));
        DataTypeDefinition type = new DefaultDataTypeDefinition(this, schema, record.get(SYSSEQUENCES.SEQUENCEDATATYPE));
        result.add(new DefaultSequenceDefinition(schema, record.get(SYSSEQUENCES.SEQUENCENAME), type, null, record.get(SYSSEQUENCES.STARTVALUE), record.get(SYSSEQUENCES.INCREMENT), record.get(SYSSEQUENCES.MINIMUMVALUE), record.get(SYSSEQUENCES.MAXIMUMVALUE), record.get(SYSSEQUENCES.CYCLEOPTION, Boolean.class), null));
    }
    return result;
}
Also used : DefaultSequenceDefinition(org.jooq.meta.DefaultSequenceDefinition) SchemaDefinition(org.jooq.meta.SchemaDefinition) DefaultSequenceDefinition(org.jooq.meta.DefaultSequenceDefinition) SequenceDefinition(org.jooq.meta.SequenceDefinition) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition) ArrayList(java.util.ArrayList) Record(org.jooq.Record) DataTypeDefinition(org.jooq.meta.DataTypeDefinition) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition)

Example 5 with DefaultSequenceDefinition

use of org.jooq.meta.DefaultSequenceDefinition in project jOOQ by jOOQ.

the class MariaDBDatabase method getSequences0.

@Override
protected List<SequenceDefinition> getSequences0() throws SQLException {
    List<SequenceDefinition> result = new ArrayList<>();
    for (Record record : create().select(TABLES.TABLE_SCHEMA, TABLES.TABLE_NAME).from(TABLES).where(TABLES.TABLE_TYPE.eq("SEQUENCE"))) {
        SchemaDefinition schema = getSchema(record.get(TABLES.TABLE_SCHEMA));
        if (schema != null) {
            String name = record.get(TABLES.TABLE_NAME);
            DefaultDataTypeDefinition type = new DefaultDataTypeDefinition(this, schema, BIGINT.getTypeName());
            Field<Long> startWith = nullif(field("start_value", BIGINT), inline(1L));
            Field<Long> incrementBy = nullif(field("increment", BIGINT), inline(1L));
            Field<Long> minValue = inline(field("minimum_value", BIGINT), inline(1L));
            Field<Long> maxValue = nullif(field("maximum_value", BIGINT), inline(DEFAULT_SEQUENCE_MAXVALUE));
            Field<Boolean> cycle = field("cycle_option", BOOLEAN);
            Field<Long> cache = nullif(field("cache_size", BIGINT), inline(DEFAULT_SEQUENCE_CACHE));
            Record flags = create().select(startWith, incrementBy, minValue, maxValue, cycle, cache).from(name(schema.getName(), name)).fetchOne();
            result.add(new DefaultSequenceDefinition(schema, name, type, null, flags.get(startWith), flags.get(incrementBy), flags.get(minValue), flags.get(maxValue), flags.get(cycle), flags.get(cache)));
        }
    }
    return result;
}
Also used : DefaultSequenceDefinition(org.jooq.meta.DefaultSequenceDefinition) SchemaDefinition(org.jooq.meta.SchemaDefinition) SequenceDefinition(org.jooq.meta.SequenceDefinition) DefaultSequenceDefinition(org.jooq.meta.DefaultSequenceDefinition) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition) ArrayList(java.util.ArrayList) Record(org.jooq.Record)

Aggregations

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