Search in sources :

Example 1 with DfSequenceIdentityProperties

use of org.dbflute.properties.DfSequenceIdentityProperties in project dbflute-core by dbflute.

the class Table method getSequenceIncrementSize.

public Integer getSequenceIncrementSize() {
    if (!isUseSequence()) {
        return null;
    }
    final DfSequenceIdentityProperties prop = getSequenceIdentityProperties();
    final DfSchemaSource ds = getDatabase().getDataSource();
    Integer size = prop.getSequenceIncrementSizeByTableName(ds, getUnifiedSchema(), getTableDbName());
    if (size == null) {
        final String sequenceName = extractPostgreSQLSerialSequenceName();
        if (sequenceName != null && sequenceName.trim().length() > 0) {
            size = prop.getSequenceIncrementSizeBySequenceName(ds, getUnifiedSchema(), sequenceName);
        }
    }
    return size;
}
Also used : DfSchemaSource(org.dbflute.helper.jdbc.context.DfSchemaSource) DfSequenceIdentityProperties(org.dbflute.properties.DfSequenceIdentityProperties)

Example 2 with DfSequenceIdentityProperties

use of org.dbflute.properties.DfSequenceIdentityProperties in project dbflute-core by dbflute.

the class Table method getSubColumnSequenceColumnList.

public List<Column> getSubColumnSequenceColumnList() {
    if (_subColumnSequenceColumnList != null) {
        return _subColumnSequenceColumnList;
    }
    _subColumnSequenceColumnList = DfCollectionUtil.newArrayList();
    final DfSequenceIdentityProperties prop = getSequenceIdentityProperties();
    if (!prop.hasSubColumnSequence()) {
        return _subColumnSequenceColumnList;
    }
    final List<Column> columnList = getColumnList();
    for (Column column : columnList) {
        final String sequenceName = prop.getSubColumnSequenceName(getTableDbName(), column.getName());
        if (sequenceName != null) {
            _subColumnSequenceColumnList.add(column);
        }
    }
    return _subColumnSequenceColumnList;
}
Also used : DfSequenceIdentityProperties(org.dbflute.properties.DfSequenceIdentityProperties)

Example 3 with DfSequenceIdentityProperties

use of org.dbflute.properties.DfSequenceIdentityProperties in project dbflute-core by dbflute.

the class Table method getSequenceMaximumValue.

public BigDecimal getSequenceMaximumValue() {
    if (!isUseSequence()) {
        return null;
    }
    final DfSequenceIdentityProperties prop = getSequenceIdentityProperties();
    final DfSchemaSource ds = getDatabase().getDataSource();
    BigDecimal value = prop.getSequenceMaximumValueByTableName(ds, getUnifiedSchema(), getTableDbName());
    if (value == null) {
        final String sequenceName = extractPostgreSQLSerialSequenceName();
        if (sequenceName != null && sequenceName.trim().length() > 0) {
            value = prop.getSequenceMaximumValueBySequenceName(ds, getUnifiedSchema(), sequenceName);
        }
    }
    return value;
}
Also used : DfSchemaSource(org.dbflute.helper.jdbc.context.DfSchemaSource) DfSequenceIdentityProperties(org.dbflute.properties.DfSequenceIdentityProperties) BigDecimal(java.math.BigDecimal)

Example 4 with DfSequenceIdentityProperties

use of org.dbflute.properties.DfSequenceIdentityProperties in project dbflute-core by dbflute.

the class DfTakeFinallyProcess method incrementSequenceToDataMax.

// -----------------------------------------------------
// Increment Sequence
// ------------------
protected void incrementSequenceToDataMax() {
    if (!getReplaceSchemaProperties().isIncrementSequenceToDataMax()) {
        return;
    }
    if (_suppressSequenceIncrement) {
        return;
    }
    _log.info("");
    _log.info("* * * * * * * * * * **");
    _log.info("*                    *");
    _log.info("* Increment Sequence *");
    _log.info("*                    *");
    _log.info("* * * * * * * * * * **");
    final DfSequenceIdentityProperties sequenceProp = getProperties().getSequenceIdentityProperties();
    final Map<String, String> tableSequenceMap = sequenceProp.getTableSequenceMap();
    final DfDatabaseTypeFacadeProp dbTypeProp = getDatabaseTypeFacadeProp();
    final DfDatabaseProperties databaseProp = getDatabaseProperties();
    final DfSequenceHandlerFactory factory = new DfSequenceHandlerFactory(_dataSource, dbTypeProp, databaseProp);
    final DfSequenceHandler sequenceHandler = factory.createSequenceHandler();
    if (sequenceHandler == null) {
        String databaseType = dbTypeProp.getTargetDatabase();
        String msg = "Unsupported isIncrementSequenceToDataMax at " + databaseType;
        throw new UnsupportedOperationException(msg);
    }
    sequenceHandler.incrementSequenceToDataMax(tableSequenceMap);
}
Also used : DfSequenceHandler(org.dbflute.logic.replaceschema.takefinally.sequence.DfSequenceHandler) DfSequenceHandlerFactory(org.dbflute.logic.replaceschema.takefinally.sequence.factory.DfSequenceHandlerFactory) DfDatabaseTypeFacadeProp(org.dbflute.properties.facade.DfDatabaseTypeFacadeProp) DfSequenceIdentityProperties(org.dbflute.properties.DfSequenceIdentityProperties) DfDatabaseProperties(org.dbflute.properties.DfDatabaseProperties)

Example 5 with DfSequenceIdentityProperties

use of org.dbflute.properties.DfSequenceIdentityProperties in project dbflute-core by dbflute.

the class Table method getIdentityColumn.

protected Column getIdentityColumn() {
    if (!isUseIdentity()) {
        return null;
    }
    // It gives priority to auto-increment information of JDBC.
    final Column autoIncrementColumn = getAutoIncrementColumn();
    if (autoIncrementColumn != null) {
        return autoIncrementColumn;
    }
    final DfSequenceIdentityProperties prop = getSequenceIdentityProperties();
    final String columnName = prop.getIdentityColumnName(getTableDbName());
    final Column column = getColumn(columnName);
    if (column == null) {
        String msg = "The columnName does not exist in the table: ";
        msg = msg + " tableName=" + getTableDbName() + " columnName=" + columnName;
        msg = msg + " columnList=" + getColumnNameCommaString();
        throw new IllegalStateException(msg);
    }
    return column;
}
Also used : DfSequenceIdentityProperties(org.dbflute.properties.DfSequenceIdentityProperties)

Aggregations

DfSequenceIdentityProperties (org.dbflute.properties.DfSequenceIdentityProperties)9 DfSchemaSource (org.dbflute.helper.jdbc.context.DfSchemaSource)4 BigDecimal (java.math.BigDecimal)2 DfSequenceHandler (org.dbflute.logic.replaceschema.takefinally.sequence.DfSequenceHandler)1 DfSequenceHandlerFactory (org.dbflute.logic.replaceschema.takefinally.sequence.factory.DfSequenceHandlerFactory)1 DfBasicProperties (org.dbflute.properties.DfBasicProperties)1 DfDatabaseProperties (org.dbflute.properties.DfDatabaseProperties)1 DfDatabaseTypeFacadeProp (org.dbflute.properties.facade.DfDatabaseTypeFacadeProp)1