use of org.dbflute.exception.DfPropertySettingColumnNotFoundException in project dbflute-core by dbflute.
the class DfAdditionalPrimaryKeyInitializer method assertColumnList.
protected void assertColumnList(final String primaryKeyName, final String tableName, List<String> columnNameList) {
if (getTable(tableName).containsColumn(columnNameList)) {
return;
}
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("Not found table by the tableName of additionalPrimaryKey.");
br.addItem("Additional PK");
br.addElement(primaryKeyName);
br.addItem("Table");
br.addElement(tableName);
br.addItem("NotFound Column");
br.addElement(columnNameList);
final String msg = br.buildExceptionMessage();
throw new DfPropertySettingColumnNotFoundException(msg);
}
use of org.dbflute.exception.DfPropertySettingColumnNotFoundException in project dbflute-core by dbflute.
the class DfAdditionalUniqueKeyInitializer method assertColumnList.
protected void assertColumnList(final String primaryKeyName, final String tableName, List<String> columnNameList) {
if (getTable(tableName).containsColumn(columnNameList)) {
return;
}
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("Not found table by the tableName of additionalUniqueKey.");
br.addItem("Additional UQ");
br.addElement(primaryKeyName);
br.addItem("Table");
br.addElement(tableName);
br.addItem("NotFound Column");
br.addElement(columnNameList);
final String msg = br.buildExceptionMessage();
throw new DfPropertySettingColumnNotFoundException(msg);
}
use of org.dbflute.exception.DfPropertySettingColumnNotFoundException in project dbflute-core by dbflute.
the class DfAdditionalForeignKeyInitializer method assertForeignTableColumn.
protected void assertForeignTableColumn(String foreignKeyName, String foreignTableName, List<String> foreignColumnNameList) {
if (getTable(foreignTableName).containsColumn(foreignColumnNameList)) {
return;
}
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("Not found column by the foreignColumnName of additionalForeignKey.");
br.addItem("Advice");
br.addElement("Make sure your additionalForeignKeyMap.dfprop");
br.addElement("For example:");
br.addElement(" (x):");
br.addElement(" ; FK_MEMBER_MEMBER_ADDRESS_VALID = map:{");
br.addElement(" ; localTableName = ... ; foreignTableName = ...");
br.addElement(" ; localColumnName = MEMBER_ID ; foreignColumnName = NOEXISTING_ID // *NG");
br.addElement(" ...");
br.addElement(" }");
br.addElement(" (o):");
br.addElement(" ; FK_MEMBER_MEMBER_ADDRESS_VALID = map:{");
br.addElement(" ; localTableName = ... ; foreignTableName = MEMBER_ADDRESS");
br.addElement(" ; localColumnName = MEMBER_ID ; foreignColumnName = MEMBER_ID // OK");
br.addElement(" ...");
br.addElement(" }");
br.addItem("Additional FK");
br.addElement(foreignKeyName);
br.addItem("Foreign Table");
br.addElement(foreignTableName);
br.addItem("NotFound Column");
br.addElement(foreignColumnNameList);
final String msg = br.buildExceptionMessage();
throw new DfPropertySettingColumnNotFoundException(msg);
}
use of org.dbflute.exception.DfPropertySettingColumnNotFoundException in project dbflute-core by dbflute.
the class DfAdditionalForeignKeyInitializer method assertLocalTableColumn.
protected void assertLocalTableColumn(final String foreignKeyName, final String localTableName, List<String> localColumnNameList, DfAdditionalForeignKeyOption resource) {
if (resource.isFixedOnlyJoin()) {
if (!localColumnNameList.isEmpty()) {
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("The localColumn should be omitted when fixedOnlyJoin is true.");
br.addItem("Additional FK");
br.addElement(foreignKeyName);
br.addItem("Local Table");
br.addElement(localTableName);
br.addItem("Column List");
br.addElement(localColumnNameList);
final String msg = br.buildExceptionMessage();
throw new DfIllegalPropertySettingException(msg);
}
} else {
if (!getTable(localTableName).containsColumn(localColumnNameList)) {
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("Not found column by the localColumnName of additionalForeignKey.");
br.addElement("Make sure your additionalForeignKeyMap.dfprop");
br.addElement("For example:");
br.addElement(" (x):");
br.addElement(" ; FK_MEMBER_MEMBER_ADDRESS_VALID = map:{");
br.addElement(" ; localTableName = ... ; foreignTableName = ...");
br.addElement(" ; localColumnName = NOEXISTING_ID ; foreignColumnName = MEMBER_ID // *NG");
br.addElement(" ...");
br.addElement(" }");
br.addElement(" (o):");
br.addElement(" ; FK_MEMBER_MEMBER_ADDRESS_VALID = map:{");
br.addElement(" ; localTableName = ... ; foreignTableName = MEMBER_ADDRESS");
br.addElement(" ; localColumnName = MEMBER_ID ; foreignColumnName = MEMBER_ID // OK");
br.addElement(" ...");
br.addElement(" }");
br.addItem("Additional FK");
br.addElement(foreignKeyName);
br.addItem("Local Table");
br.addElement(localTableName);
br.addItem("NotFound Column");
br.addElement(localColumnNameList);
final String msg = br.buildExceptionMessage();
throw new DfPropertySettingColumnNotFoundException(msg);
}
}
}
use of org.dbflute.exception.DfPropertySettingColumnNotFoundException in project dbflute-core by dbflute.
the class DfAdditionalForeignKeyInitializer method getLocalColumnNameList.
protected List<String> getLocalColumnNameList(Table table, String foreignKeyName, String foreignTableName, List<String> foreignColumnNameList, String localTableName, DfAdditionalForeignKeyOption option, boolean searchFromExistingFK, boolean errorIfNotFound) {
List<String> localColumnNameList = getLocalColumnNameList(foreignKeyName);
if (localColumnNameList != null && !localColumnNameList.isEmpty()) {
return localColumnNameList;
}
// searching from existing foreign key
if (searchFromExistingFK) {
final ForeignKey existingFK = table.findExistingForeignKey(foreignTableName, foreignColumnNameList, option.getFixedSuffix());
if (existingFK != null) {
return existingFK.getLocalColumnNameList();
}
}
// searching local columns by foreign columns (PK or UQ: PK when omitted)
localColumnNameList = DfCollectionUtil.newArrayList();
if (option.isFixedOnlyJoin()) {
// no need to search
return localColumnNameList;
}
for (String foreignColumnName : foreignColumnNameList) {
final Column column = table.getColumn(foreignColumnName);
if (column != null) {
// no check about same-column self reference here
localColumnNameList.add(column.getName());
continue;
}
if (errorIfNotFound) {
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("Not found the local column by the foreign column of additionalForeignKey.");
br.addItem("Advice");
br.addElement("When localColumnName is omitted, the local table should have");
br.addElement("the columns that are same as primary keys of foreign table.");
br.addItem("Additional FK");
br.addElement(foreignKeyName);
br.addElement(option);
br.addItem("Local Table");
br.addElement(localTableName);
br.addItem("Foreign Table");
br.addElement(foreignTableName);
br.addItem("Foreign Column");
br.addElement(foreignColumnNameList);
final String msg = br.buildExceptionMessage();
throw new DfPropertySettingColumnNotFoundException(msg);
} else {
// means not found
return DfCollectionUtil.newArrayList();
}
}
return localColumnNameList;
}
Aggregations