List of usage examples for org.hibernate.dialect Dialect dropConstraints
public boolean dropConstraints()
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) {//from ww w. j a v a 2 s. co m 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
/** * Based on/*from w ww .ja va 2 s . co m*/ * {@link org.hibernate.cfg.Configuration#generateDropSchemaScript(Dialect)} * . Rewritten to only create drop commands for existing tables/sequences. * * * @param d * @param m * * @return SQL script to drop schema as String array * * @throws HibernateException */ public String[] generateDropSchemaScript(final Dialect d, final DatabaseMetadata m) throws HibernateException { secondPassCompile(); final String c = getProperties().getProperty(Environment.DEFAULT_CATALOG); final String s = getProperties().getProperty(Environment.DEFAULT_SCHEMA); final List<String> script = new LinkedList<String>(); script.addAll(generateAuxiliaryDatabaseObjectDropScript(d, c, s)); if (d.dropConstraints()) { script.addAll(generateConstraintDropScript(d, c, s, m)); } script.addAll(generateTableDropScript(d, c, s, m)); script.addAll(generateIdentifierGeneratorDropScript(d, c, s, m)); return ArrayHelper.toStringArray(script); }