use of org.dbflute.logic.jdbc.metadata.info.DfSynonymMeta in project dbflute-core by dbflute.
the class DfSchemaXmlSerializer method getPrimaryColumnMetaInfo.
// -----------------------------------------------------
// Primary Key
// -----------
/**
* Get the meta information of primary key.
* @param metaData The meta data of a database. (NotNull)
* @param tableMeta The meta information of table. (NotNull)
* @return The meta information of primary key. (NotNull)
* @throws SQLException When it fails to handle the SQL.
*/
protected DfPrimaryKeyMeta getPrimaryColumnMetaInfo(DatabaseMetaData metaData, DfTableMeta tableMeta) throws SQLException {
final DfPrimaryKeyMeta pkInfo = _uniqueKeyExtractor.getPrimaryKey(metaData, tableMeta);
final List<String> pkList = pkInfo.getPrimaryKeyList();
if (!canHandleSynonym(tableMeta) || !pkList.isEmpty()) {
return pkInfo;
}
final DfSynonymMeta synonym = getSynonymMetaInfo(tableMeta);
if (synonym != null) {
return synonym.getPrimaryKey();
} else {
return pkInfo;
}
}
use of org.dbflute.logic.jdbc.metadata.info.DfSynonymMeta in project dbflute-core by dbflute.
the class DfSchemaXmlSerializer method getForeignKeys.
// -----------------------------------------------------
// Foreign Key
// -----------
/**
* Retrieves a list of foreign key columns for a given table.
* @param conn The connection for the foreign keys, basically for info cannot be provided from meta data, e.g. to-UQ FK. (NotNull)
* @param metaData The meta data of a database. (NotNull)
* @param tableMeta The meta information of table. (NotNull)
* @return A list of foreign keys in <code>tableName</code>.
* @throws SQLException When it fails to handle the SQL.
*/
protected Map<String, DfForeignKeyMeta> getForeignKeys(Connection conn, DatabaseMetaData metaData, DfTableMeta tableMeta) throws SQLException {
final Map<String, DfForeignKeyMeta> foreignKeyMap = _foreignKeyExtractor.getForeignKeyMap(conn, metaData, tableMeta);
if (!canHandleSynonym(tableMeta) || !foreignKeyMap.isEmpty()) {
return foreignKeyMap;
}
final DfSynonymMeta synonym = getSynonymMetaInfo(tableMeta);
return synonym != null ? synonym.getForeignKeyMap() : foreignKeyMap;
}
use of org.dbflute.logic.jdbc.metadata.info.DfSynonymMeta in project dbflute-core by dbflute.
the class DfSchemaXmlSerializer method getIndexMap.
// -----------------------------------------------------
// Index
// -----
/**
* Get index column name list.
* @param metaData The meta data of a database. (NotNull)
* @param tableMeta The meta information of table. (NotNull)
* @param uniqueKeyMap The map of unique key. (NotNull)
* @return The list of index columns. (NotNull)
* @throws SQLException When it fails to handle the SQL.
*/
protected Map<String, Map<Integer, String>> getIndexMap(DatabaseMetaData metaData, DfTableMeta tableMeta, Map<String, Map<Integer, String>> uniqueKeyMap) throws SQLException {
final Map<String, Map<Integer, String>> indexMap = _indexExtractor.getIndexMap(metaData, tableMeta, uniqueKeyMap);
if (!canHandleSynonym(tableMeta) || !indexMap.isEmpty()) {
return indexMap;
}
final DfSynonymMeta synonym = getSynonymMetaInfo(tableMeta);
return synonym != null ? synonym.getIndexMap() : indexMap;
}
use of org.dbflute.logic.jdbc.metadata.info.DfSynonymMeta in project dbflute-core by dbflute.
the class DfSchemaXmlSerializer method helpColumnAdjustment.
protected List<DfColumnMeta> helpColumnAdjustment(DatabaseMetaData dbMeta, DfTableMeta tableMeta, List<DfColumnMeta> columnList) {
if (!canHandleSynonym(tableMeta)) {
return columnList;
}
final DfSynonymMeta synonym = getSynonymMetaInfo(tableMeta);
if (synonym == null) {
// means not synonym or no supplementary info
return columnList;
}
final List<DfColumnMeta> metaInfoList = synonym.getColumnMetaInfoList();
if (metaInfoList.isEmpty()) {
return metaInfoList;
}
if (synonym.isDBLink() && columnList.isEmpty()) {
columnList = metaInfoList;
} else if (metaInfoList.size() != columnList.size()) {
// for Oracle's bug(?), which is following:
// /- - - - - - - - - - - - - - - - - - - - - - - - - - -
// For example, Schema A, B are like this:
// A: FOO table
// B: FOO table, BAR synonym to A's FOO table
// BAR synonym's columns are from both A and B's FOO table.
// (means that BAR synonym has other table's columns)
// Why? my friend, the Oracle JDBC Driver!
// - - - - - - - - - -/
final StringSet columnSet = StringSet.createAsCaseInsensitive();
for (DfColumnMeta columnMeta : metaInfoList) {
columnSet.add(columnMeta.getColumnName());
}
final List<DfColumnMeta> filteredList = new ArrayList<DfColumnMeta>();
for (DfColumnMeta columnMeta : columnList) {
if (columnSet.contains(columnMeta.getColumnName())) {
filteredList.add(columnMeta);
}
}
columnList = filteredList;
}
return columnList;
}
Aggregations