Example usage for org.hibernate.mapping Table sqlDropString

List of usage examples for org.hibernate.mapping Table sqlDropString

Introduction

In this page you can find the example usage for org.hibernate.mapping Table sqlDropString.

Prototype

public String sqlDropString(Dialect dialect, String defaultCatalog, String defaultSchema) 

Source Link

Usage

From source file:com.opengamma.util.db.tool.DbToolTest.java

License:Open Source License

private void createTestTable() throws SQLException {
    Table table = new Table(TEST_TABLE);
    try {// w ww . j  av  a2s  . c  om
        String dropSql = table.sqlDropString(_tool.getHibernateDialect(), null, _tool.getTestSchema());
        _tool.executeSql(_tool.getTestCatalog(), _tool.getTestSchema(), dropSql);
    } catch (OpenGammaRuntimeException e) {
        // It might not exist, that's OK
    }
    String createSql = "CREATE TABLE "
            + table.getQualifiedName(_tool.getHibernateDialect(), null, _tool.getTestSchema())
            + " (test_column char(50))";
    _tool.executeSql(_tool.getTestCatalog(), _tool.getTestSchema(), createSql);
}

From source file:com.zutubi.pulse.master.hibernate.SchemaRefactor.java

License:Apache License

protected void dropTable(Connection connection, Table table) throws SQLException {
    String sql = table.sqlDropString(dialect, defaultCatalog, defaultSchema);
    LOG.info(sql);/*from   w w  w . ja v a 2  s.c  o m*/
    JDBCUtils.execute(connection, sql);
    config.removeTable(table);
}

From source file:corner.migration.services.impl.MigrationServiceImpl.java

License:Apache License

/**
 * /*from w ww.ja  v  a 2  s  .c  o  m*/
 * 
 * @param tableName
 *            ??
 * @since 0.0.2
 * @see corner.migration.services.MigrationService#dropTable(java.lang.String)
 */
@Override
public void dropTable(String tableName) {
    Table table = new Table(tableName);
    this.executeSchemaScript(table.sqlDropString(this.dialect, defaultCatalog, defaultSchema));
}

From source file:corner.services.migration.impl.MigrationServiceImpl.java

License:Apache License

/**
 * //from  w  ww.  java 2s .c  o  m
 * 
 * @param tableName
 *            ??
 * @since 0.0.2
 */
public void dropTable(String tableName) {
    Table table = new Table(tableName);
    this.executeSchemaScript(table.sqlDropString(this.dialect, defaultCatalog, defaultSchema));
}

From source file:org.apereo.portal.tools.dbloader.HibernateDbLoader.java

License:Apache License

/** Generate the drop scripts and add them to the script list */
@SuppressWarnings("unchecked")
protected List<String> dropScript(Collection<Table> tables, Dialect dialect, String defaultCatalog,
        String defaultSchema) {/*w ww. j  a va  2  s  .  c om*/
    final List<String> script = new ArrayList<String>(tables.size() * 2);

    if (dialect.dropConstraints()) {
        for (final Table table : tables) {
            if (table.isPhysicalTable()) {
                for (final Iterator<ForeignKey> subIter = table.getForeignKeyIterator(); subIter.hasNext();) {
                    final ForeignKey fk = subIter.next();
                    if (fk.isPhysicalConstraint()) {
                        script.add(fk.sqlDropString(dialect, defaultCatalog, defaultSchema));
                    }
                }
            }
        }
    }

    for (final Table table : tables) {
        if (table.isPhysicalTable()) {
            script.add(table.sqlDropString(dialect, defaultCatalog, defaultSchema));
        }
    }

    return script;
}

From source file:org.n52.sos.ds.datasource.CustomConfiguration.java

License:Open Source License

protected List<String> generateTableDropScript(final Dialect d, final String c, final String s,
        final DatabaseMetadata m) throws HibernateException {
    final List<String> script = new LinkedList<String>();
    final Iterator<Table> itr = getTableMappings();
    while (itr.hasNext()) {
        final Table table = itr.next();
        // TODO remove because fails if table definition is quoted
        //            final String tableName = table.getQualifiedName(d, c, s);
        if (checkTable(table, m)) {
            script.add(table.sqlDropString(d, c, s));
        }/*from   ww w .j av a  2  s.  c om*/
    }
    return script;
}