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;
}
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;
}
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;
}
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);
}
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;
}
Aggregations