Example usage for java.sql DatabaseMetaData importedKeyNoAction

List of usage examples for java.sql DatabaseMetaData importedKeyNoAction

Introduction

In this page you can find the example usage for java.sql DatabaseMetaData importedKeyNoAction.

Prototype

int importedKeyNoAction

To view the source code for java.sql DatabaseMetaData importedKeyNoAction.

Click Source Link

Document

For the columns UPDATE_RULE and DELETE_RULE, indicates that if the primary key has been imported, it cannot be updated or deleted.

Usage

From source file:org.executequery.databaseobjects.impl.TableColumnConstraint.java

private String translateUpdateRule(Short value) {

    String translated = String.valueOf(value);
    if (isForeignKey()) {

        switch (value) {
        case DatabaseMetaData.importedKeyNoAction:
            return translated + " - importedKeyNoAction";

        case DatabaseMetaData.importedKeyCascade:
            return translated + " - importedKeyCascade";

        case DatabaseMetaData.importedKeySetNull:
            return translated + " - importedKeySetNull";

        case DatabaseMetaData.importedKeyRestrict:
            return translated + " - importedKeyRestrict";

        case DatabaseMetaData.importedKeySetDefault:
            return translated + " - importedKeySetDefault";
        }/*from  w  w  w .ja v  a2  s . c  o m*/

    }
    return translated;
}

From source file:org.executequery.sql.spi.LiquibaseStatementGenerator.java

private String addForeignKey(ColumnConstraint constraint, Database database) {

    AddForeignKeyConstraintChange change = new AddForeignKeyConstraintChange();
    change.setBaseTableName(constraint.getTableName());
    change.setBaseColumnNames(constraint.getColumnName());
    change.setConstraintName(constraint.getName());
    change.setReferencedTableName(constraint.getReferencedTable());
    change.setReferencedColumnNames(constraint.getReferencedColumn());

    if (constraint.getDeleteRule() != DatabaseMetaData.importedKeyNoAction) {

        change.setOnDelete(getForeignKeyConstraintType(constraint.getDeleteRule()));
    }/*from  w  w w  . j  av a2s.  c  o m*/

    if (constraint.getUpdateRule() != DatabaseMetaData.importedKeyNoAction) {

        change.setOnUpdate(getForeignKeyConstraintType(constraint.getUpdateRule()));
    }

    return generateStatements(change, database);
}

From source file:org.executequery.sql.spi.LiquibaseStatementGenerator.java

private ForeignKeyConstraintType getForeignKeyConstraintType(short rule) {

    switch (rule) {

    case DatabaseMetaData.importedKeyCascade:
        return ForeignKeyConstraintType.importedKeyCascade;

    case DatabaseMetaData.importedKeySetNull:
        return ForeignKeyConstraintType.importedKeySetNull;

    case DatabaseMetaData.importedKeyRestrict:
        return ForeignKeyConstraintType.importedKeyRestrict;

    case DatabaseMetaData.importedKeySetDefault:
        return ForeignKeyConstraintType.importedKeySetDefault;

    case DatabaseMetaData.importedKeyNoAction:
    default:/*w w w  . j a va 2  s  .c o  m*/
        return ForeignKeyConstraintType.importedKeyNoAction;

    }

}