Search in sources :

Example 1 with SpecifyUpdateColumnInvalidException

use of org.dbflute.exception.SpecifyUpdateColumnInvalidException in project dbflute-core by dbflute.

the class InsertOption method xcheckSpecifiedInsertColumnPrimaryKey.

// -----------------------------------------------------
// Insert Process
// --------------
public void xcheckSpecifiedInsertColumnPrimaryKey() {
    // checked later by process if it needs
    if (_insertColumnSpecification == null) {
        return;
    }
    assertInsertColumnSpecifiedCB();
    final CB cb = _insertColumnSpecifiedCB;
    final String basePointAliasName = cb.getSqlClause().getBasePointAliasName();
    final DBMeta dbmeta = cb.asDBMeta();
    if (dbmeta.hasPrimaryKey()) {
        final PrimaryInfo pkInfo = dbmeta.getPrimaryInfo();
        final List<ColumnInfo> pkList = pkInfo.getPrimaryColumnList();
        for (ColumnInfo pk : pkList) {
            final String columnDbName = pk.getColumnDbName();
            if (cb.getSqlClause().hasSpecifiedSelectColumn(basePointAliasName, columnDbName)) {
                String msg = "PK columns should not be allowed to specify as update columns: " + columnDbName;
                throw new SpecifyUpdateColumnInvalidException(msg);
            }
        }
    }
}
Also used : DBMeta(org.dbflute.dbmeta.DBMeta) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo) SpecifyUpdateColumnInvalidException(org.dbflute.exception.SpecifyUpdateColumnInvalidException) PrimaryInfo(org.dbflute.dbmeta.info.PrimaryInfo)

Example 2 with SpecifyUpdateColumnInvalidException

use of org.dbflute.exception.SpecifyUpdateColumnInvalidException in project dbflute-core by dbflute.

the class UpdateOption method xcheckSpecifiedUpdateColumnPrimaryKey.

// -----------------------------------------------------
// Update Process
// --------------
public void xcheckSpecifiedUpdateColumnPrimaryKey() {
    // checked later by process if it needs
    if (_updateColumnSpecification == null) {
        return;
    }
    assertUpdateColumnSpecifiedCB();
    final CB cb = _updateColumnSpecifiedCB;
    final String basePointAliasName = cb.getSqlClause().getBasePointAliasName();
    final DBMeta dbmeta = cb.asDBMeta();
    if (dbmeta.hasPrimaryKey()) {
        final PrimaryInfo pkInfo = dbmeta.getPrimaryInfo();
        final List<ColumnInfo> pkList = pkInfo.getPrimaryColumnList();
        for (ColumnInfo pk : pkList) {
            final String columnDbName = pk.getColumnDbName();
            if (cb.getSqlClause().hasSpecifiedSelectColumn(basePointAliasName, columnDbName)) {
                String msg = "PK columns should not be allowed to specify as update columns: " + columnDbName;
                throw new SpecifyUpdateColumnInvalidException(msg);
            }
        }
    }
}
Also used : DBMeta(org.dbflute.dbmeta.DBMeta) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo) SpecifyUpdateColumnInvalidException(org.dbflute.exception.SpecifyUpdateColumnInvalidException) PrimaryInfo(org.dbflute.dbmeta.info.PrimaryInfo)

Aggregations

DBMeta (org.dbflute.dbmeta.DBMeta)2 ColumnInfo (org.dbflute.dbmeta.info.ColumnInfo)2 PrimaryInfo (org.dbflute.dbmeta.info.PrimaryInfo)2 SpecifyUpdateColumnInvalidException (org.dbflute.exception.SpecifyUpdateColumnInvalidException)2