当前位置: 首页>>代码示例>>Java>>正文


Java Database.findTable方法代码示例

本文整理汇总了Java中org.apache.ddlutils.model.Database.findTable方法的典型用法代码示例。如果您正苦于以下问题:Java Database.findTable方法的具体用法?Java Database.findTable怎么用?Java Database.findTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ddlutils.model.Database的用法示例。


在下文中一共展示了Database.findTable方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createUpdateSql

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Creates the SQL for updating an object of the given type. If a concrete bean is given,
 * then a concrete update statement is created, otherwise an update statement usable in a
 * prepared statement is build.
 * 
 * @param model       The database model
 * @param dynaClass   The type
 * @param primaryKeys The primary keys
 * @param properties  The properties to write
 * @param oldBean     Contains column values to identify the rows to update (i.e. for the WHERE clause)
 * @param newBean     Contains the new column values to write
 * @return The SQL required to update the instance
 */
protected String createUpdateSql(Database model, SqlDynaClass dynaClass, SqlDynaProperty[] primaryKeys, SqlDynaProperty[] properties, DynaBean oldBean, DynaBean newBean)
{
    Table   table           = model.findTable(dynaClass.getTableName());
    HashMap oldColumnValues = toColumnValues(primaryKeys, oldBean);
    HashMap newColumnValues = toColumnValues(properties, newBean);

    if (primaryKeys.length == 0)
    {
        _log.info("Cannot update instances of type " + dynaClass + " because it has no primary keys");
        return null;
    }
    else
    {
        return _builder.getUpdateSql(table, oldColumnValues, newColumnValues, newBean == null);
    }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:30,代码来源:PlatformImplBase.java

示例2: compareModels

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Compares the given source and target models and creates change objects to get from
 * the source to the target one. These changes will be applied to the given
 * intermediate model (the other two won't be changed), so that it will be equal to
 * the target model after this model has finished.
 * 
 * @param sourceModel       The source model
 * @param intermediateModel The intermediate model to apply the changes to
 * @param targetModel       The target model
 * @return The changes
 */
protected List compareModels(Database sourceModel,
                             Database intermediateModel,
                             Database targetModel)
{
    ArrayList changes = new ArrayList();

    changes.addAll(checkForRemovedForeignKeys(sourceModel, intermediateModel, targetModel));
    changes.addAll(checkForRemovedTables(sourceModel, intermediateModel, targetModel));

    for (int tableIdx = 0; tableIdx < intermediateModel.getTableCount(); tableIdx++)
    {
        Table intermediateTable = intermediateModel.getTable(tableIdx);
        Table sourceTable       = sourceModel.findTable(intermediateTable.getQualifiedName(), _caseSensitive);
        Table targetTable       = targetModel.findTable(intermediateTable.getQualifiedName(), _caseSensitive);
        List  tableChanges      = compareTables(sourceModel, sourceTable,
                                                intermediateModel, intermediateTable,
                                                targetModel, targetTable);

        changes.addAll(tableChanges);
    }

    changes.addAll(checkForAddedTables(sourceModel, intermediateModel, targetModel));
    changes.addAll(checkForAddedForeignKeys(sourceModel, intermediateModel, targetModel));
    return changes;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:37,代码来源:ModelComparator.java

示例3: findChangedTable

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Finds the table changed by the change object in the given model.
 *  
 * @param currentModel The model to find the table in
 * @param change       The table change
 * @return The table
 * @throws ModelException If the table could not be found
 */
protected Table findChangedTable(Database currentModel, TableChange change) throws ModelException
{
    Table table = currentModel.findTable(change.getChangedTable(),
                                         getPlatformInfo().isDelimitedIdentifiersSupported());

    if (table == null)
    {
        throw new ModelException("Could not find table " + change.getChangedTable() + " in the given model");
    }
    else
    {
        return table;
    }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:23,代码来源:PlatformImplBase.java

示例4: checkForAddedForeignKeys

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
protected List checkForAddedForeignKeys(Database sourceModel,
                                        Database intermediateModel,
                                        Database targetModel)
{
    List changes           = super.checkForAddedForeignKeys(sourceModel, intermediateModel, targetModel);
    List additionalChanges = new ArrayList();

    // re-adding all foreign keys that are maintained and that use a changed column
    for (int tableIdx = 0; tableIdx < targetModel.getTableCount(); tableIdx++)
    {
        Table targetTable       = targetModel.getTable(tableIdx);
        Table sourceTable       = sourceModel.findTable(targetTable.getName(), isCaseSensitive());
        Table intermediateTable = intermediateModel.findTable(targetTable.getName(), isCaseSensitive());

        if (sourceTable != null)
        {
            for (int fkIdx = 0; fkIdx < targetTable.getForeignKeyCount(); fkIdx++)
            {
                ForeignKey targetFk       = targetTable.getForeignKey(fkIdx);
                ForeignKey sourceFk       = findCorrespondingForeignKey(sourceTable, targetFk);
                ForeignKey intermediateFk = findCorrespondingForeignKey(intermediateTable, targetFk);

                if ((sourceFk != null) && (intermediateFk == null))
                {
                    additionalChanges.add(new AddForeignKeyChange(intermediateTable.getName(), targetFk));
                }
            }
        }
    }
    for (Iterator changeIt = additionalChanges.iterator(); changeIt.hasNext();)
    {
        ((AddForeignKeyChange)changeIt.next()).apply(intermediateModel, isCaseSensitive());
    }
    changes.addAll(additionalChanges);
    return changes;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:40,代码来源:MSSqlModelComparator.java

示例5: checkForRemovedForeignKeys

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Creates change objects for foreign keys that are present in the given source model but are no longer in the target
 * model, and applies them to the given intermediate model.
 * 
 * @param sourceModel       The source model
 * @param intermediateModel The intermediate model to apply the changes to
 * @param targetModel       The target model
 * @return The changes
 */
protected List checkForRemovedForeignKeys(Database sourceModel,
                                          Database intermediateModel,
                                          Database targetModel)
{
    List changes = new ArrayList();

    for (int tableIdx = 0; tableIdx < intermediateModel.getTableCount(); tableIdx++)
    {
        Table        intermediateTable = intermediateModel.getTable(tableIdx);
        Table        targetTable       = targetModel.findTable(intermediateTable.getQualifiedName(), _caseSensitive);
        ForeignKey[] intermediateFks   = intermediateTable.getForeignKeys();

        // Dropping foreign keys from tables to be removed might not be necessary, but some databases might require it
        for (int fkIdx = 0; fkIdx < intermediateFks.length; fkIdx++)
        {
            ForeignKey sourceFk = intermediateFks[fkIdx];
            ForeignKey targetFk = targetTable == null ? null : findCorrespondingForeignKey(targetTable, sourceFk);

            if (targetFk == null)
            {
                if (_log.isInfoEnabled())
                {
                    _log.info("Foreign key " + sourceFk + " needs to be removed from table " + intermediateTable.getQualifiedName());
                }

                RemoveForeignKeyChange fkChange = new RemoveForeignKeyChange(intermediateTable.getQualifiedName(), sourceFk);

                changes.add(fkChange);
                fkChange.apply(intermediateModel, _caseSensitive);
            }
        }
    }
    return changes;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:44,代码来源:ModelComparator.java

示例6: checkForAddedForeignKeys

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Creates change objects for foreign keys that are not present in the given source model but are in the target
 * model, and applies them to the given intermediate model.
 * 
 * @param sourceModel       The source model
 * @param intermediateModel The intermediate model to apply the changes to
 * @param targetModel       The target model
 * @return The changes
 */
protected List checkForAddedForeignKeys(Database sourceModel,
                                        Database intermediateModel,
                                        Database targetModel)
{
    List changes = new ArrayList();

    for (int tableIdx = 0; tableIdx < targetModel.getTableCount(); tableIdx++)
    {
        Table targetTable       = targetModel.getTable(tableIdx);
        Table intermediateTable = intermediateModel.findTable(targetTable.getQualifiedName(), _caseSensitive);

        for (int fkIdx = 0; fkIdx < targetTable.getForeignKeyCount(); fkIdx++)
        {
            ForeignKey targetFk       = targetTable.getForeignKey(fkIdx);
            ForeignKey intermediateFk = findCorrespondingForeignKey(intermediateTable, targetFk);

            if (intermediateFk == null)
            {
                if (_log.isInfoEnabled())
                {
                    _log.info("Foreign key " + targetFk + " needs to be added to table " + intermediateTable.getQualifiedName());
                }

                intermediateFk = _cloneHelper.clone(targetFk, intermediateTable, intermediateModel, _caseSensitive);

                AddForeignKeyChange fkChange = new AddForeignKeyChange(intermediateTable.getQualifiedName(), intermediateFk);

                changes.add(fkChange);
                fkChange.apply(intermediateModel, _caseSensitive);
            }
        }
    }
    return changes;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:44,代码来源:ModelComparator.java

示例7: checkForRemovedTables

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Creates change objects for tables that are present in the given source model but are no longer in the target
 * model, and applies them to the given intermediate model.
 * 
 * @param sourceModel       The source model
 * @param intermediateModel The intermediate model to apply the changes to
 * @param targetModel       The target model
 * @return The changes
 */
protected List checkForRemovedTables(Database sourceModel,
                                     Database intermediateModel,
                                     Database targetModel)
{
    List    changes            = new ArrayList();
    Table[] intermediateTables = intermediateModel.getTables();

    for (int tableIdx = 0; tableIdx < intermediateTables.length; tableIdx++)
    {
        Table intermediateTable = intermediateTables[tableIdx];
        Table targetTable       = targetModel.findTable(intermediateTable.getQualifiedName(), _caseSensitive);

        if (targetTable == null)
        {
            if (_log.isInfoEnabled())
            {
                _log.info("Table " + intermediateTable.getQualifiedName() + " needs to be removed");
            }

            RemoveTableChange tableChange = new RemoveTableChange(intermediateTable.getQualifiedName());

            changes.add(tableChange);
            tableChange.apply(intermediateModel, _caseSensitive);
        }
    }
    return changes;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:37,代码来源:ModelComparator.java

示例8: checkForAddedTables

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Creates change objects for tables that are not present in the given source model but are in the target
 * model, and applies them to the given intermediate model.
 * 
 * @param sourceModel       The source model
 * @param intermediateModel The intermediate model to apply the changes to
 * @param targetModel       The target model
 * @return The changes
 */
protected List checkForAddedTables(Database sourceModel,
                                   Database intermediateModel,
                                   Database targetModel)
{
    List changes = new ArrayList();

    for (int tableIdx = 0; tableIdx < targetModel.getTableCount(); tableIdx++)
    {
        Table targetTable       = targetModel.getTable(tableIdx);
        Table intermediateTable = intermediateModel.findTable(targetTable.getQualifiedName(), _caseSensitive);

        if (intermediateTable == null)
        {
            if (_log.isInfoEnabled())
            {
                _log.info("Table " + targetTable.getQualifiedName() + " needs to be added");
            }

            // we're using a clone of the target table, and remove all foreign
            // keys as these will be added later
            intermediateTable = _cloneHelper.clone(targetTable, true, false, intermediateModel, _caseSensitive);

            AddTableChange tableChange = new AddTableChange(intermediateTable);

            changes.add(tableChange);
            tableChange.apply(intermediateModel, _caseSensitive);
        }
    }
    return changes;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:40,代码来源:ModelComparator.java

示例9: checkForRemovedForeignKeys

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
protected List checkForRemovedForeignKeys(Database sourceModel,
                                          Database intermediateModel,
                                          Database targetModel)
{
    List changes           = super.checkForRemovedForeignKeys(sourceModel, intermediateModel, targetModel);
    List additionalChanges = new ArrayList();

    // removing all foreign keys that are maintained and that use a changed column
    for (int tableIdx = 0; tableIdx < targetModel.getTableCount(); tableIdx++)
    {
        Table targetTable = targetModel.getTable(tableIdx);
        Table sourceTable = sourceModel.findTable(targetTable.getName(), isCaseSensitive());

        if (sourceTable != null)
        {
            List columns = getRelevantChangedColumns(sourceTable, targetTable);

            if (!columns.isEmpty())
            {
                for (int fkIdx = 0; fkIdx < targetTable.getForeignKeyCount(); fkIdx++)
                {
                    ForeignKey targetFk = targetTable.getForeignKey(fkIdx);
                    ForeignKey sourceFk = findCorrespondingForeignKey(sourceTable, targetFk);

                    if (sourceFk != null)
                    {
                        for (Iterator columnIt = columns.iterator(); columnIt.hasNext();)
                        {
                            Column targetColumn = (Column)columnIt.next();

                            if (targetFk.hasLocalColumn(targetColumn) || targetFk.hasForeignColumn(targetColumn))
                            {
                                additionalChanges.add(new RemoveForeignKeyChange(sourceTable.getName(), targetFk));
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
    for (Iterator changeIt = additionalChanges.iterator(); changeIt.hasNext();)
    {
        ((RemoveForeignKeyChange)changeIt.next()).apply(intermediateModel, isCaseSensitive());
    }
    changes.addAll(additionalChanges);
    return changes;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:52,代码来源:MSSqlModelComparator.java

示例10: findChangedTable

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public Table findChangedTable(Database model, boolean caseSensitive)
{
	return model.findTable(_tableName, caseSensitive);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:8,代码来源:TableChangeImplBase.java

示例11: createInsertSql

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Creates the SQL for inserting an object of the given type. If a concrete bean is given,
 * then a concrete insert statement is created, otherwise an insert statement usable in a
 * prepared statement is build. 
 *
 * @param model      The database model
 * @param dynaClass  The type
 * @param properties The properties to write
 * @param bean       Optionally the concrete bean to insert
 * @return The SQL required to insert an instance of the class
 */
protected String createInsertSql(Database model, SqlDynaClass dynaClass, SqlDynaProperty[] properties, DynaBean bean)
{
    Table   table        = model.findTable(dynaClass.getTableName());
    HashMap columnValues = toColumnValues(properties, bean);

    return _builder.getInsertSql(table, columnValues, bean == null);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:19,代码来源:PlatformImplBase.java

示例12: createSelectLastInsertIdSql

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Creates the SQL for querying for the id generated by the last insert of an object of the given type.
 * 
 * @param model     The database model
 * @param dynaClass The type
 * @return The SQL required for querying for the id, or <code>null</code> if the database does not
 *         support this
 */
protected String createSelectLastInsertIdSql(Database model, SqlDynaClass dynaClass)
{
    Table table = model.findTable(dynaClass.getTableName());

    return _builder.getSelectLastIdentityValues(table);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:15,代码来源:PlatformImplBase.java

示例13: createDeleteSql

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Creates the SQL for deleting an object of the given type. If a concrete bean is given,
 * then a concrete delete statement is created, otherwise a delete statement usable in a
 * prepared statement is build.
 * 
 * @param model       The database model
 * @param dynaClass   The type
 * @param primaryKeys The primary keys
 * @param bean        Optionally the concrete bean to update
 * @return The SQL required to delete the instance
 */
protected String createDeleteSql(Database model, SqlDynaClass dynaClass, SqlDynaProperty[] primaryKeys, DynaBean bean)
{
    Table   table    = model.findTable(dynaClass.getTableName());
    HashMap pkValues = toColumnValues(primaryKeys, bean);

    return _builder.getDeleteSql(table, pkValues, bean == null);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:19,代码来源:PlatformImplBase.java


注:本文中的org.apache.ddlutils.model.Database.findTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。