use of org.hibernate.mapping.ForeignKey in project uPortal by Jasig.
the class HibernateDbLoader method createScript.
/** Generate create scripts and add them to the script list */
@SuppressWarnings("unchecked")
protected List<String> createScript(Collection<Table> tables, Dialect dialect, Mapping mapping, String defaultCatalog, String defaultSchema) {
final List<String> script = new ArrayList<String>(tables.size() * 2);
for (final Table table : tables) {
if (table.isPhysicalTable()) {
script.add(table.sqlCreateString(dialect, mapping, defaultCatalog, defaultSchema));
}
}
for (final Table table : tables) {
if (table.isPhysicalTable()) {
if (!dialect.supportsUniqueConstraintInCreateAlterTable()) {
for (final Iterator<UniqueKey> subIter = table.getUniqueKeyIterator(); subIter.hasNext(); ) {
final UniqueKey uk = subIter.next();
final String constraintString = uk.sqlCreateString(dialect, mapping, defaultCatalog, defaultSchema);
if (constraintString != null) {
script.add(constraintString);
}
}
}
for (final Iterator<Index> subIter = table.getIndexIterator(); subIter.hasNext(); ) {
final Index index = subIter.next();
script.add(index.sqlCreateString(dialect, mapping, defaultCatalog, defaultSchema));
}
if (dialect.hasAlterTable()) {
for (final Iterator<ForeignKey> subIter = table.getForeignKeyIterator(); subIter.hasNext(); ) {
final ForeignKey fk = subIter.next();
if (fk.isPhysicalConstraint()) {
script.add(fk.sqlCreateString(dialect, mapping, defaultCatalog, defaultSchema));
}
}
}
}
}
return script;
}
Aggregations