org.hibernate.tool.schema.spi.Exporter Java Examples

The following examples show how to use org.hibernate.tool.schema.spi.Exporter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractSchemaMigrator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
protected void applyIndexes(
		Table table,
		TableInformation tableInformation,
		Dialect dialect,
		Metadata metadata,
		Formatter formatter,
		ExecutionOptions options,
		GenerationTarget... targets) {
	final Exporter<Index> exporter = dialect.getIndexExporter();

	final Iterator<Index> indexItr = table.getIndexIterator();
	while ( indexItr.hasNext() ) {
		final Index index = indexItr.next();
		if ( !StringHelper.isEmpty( index.getName() ) ) {
			IndexInformation existingIndex = null;
			if ( tableInformation != null ) {
				existingIndex = findMatchingIndex( index, tableInformation );
			}
			if ( existingIndex == null ) {
				applySqlStrings(
						false,
						exporter.getSqlCreateStrings( index, metadata ),
						formatter,
						options,
						targets
				);
			}
		}
	}
}
 
Example #2
Source File: AbstractSchemaMigrator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
protected void applyForeignKeys(
		Table table,
		TableInformation tableInformation,
		Dialect dialect,
		Metadata metadata,
		Formatter formatter,
		ExecutionOptions options,
		GenerationTarget... targets) {
	if ( dialect.hasAlterTable() ) {
		final Exporter<ForeignKey> exporter = dialect.getForeignKeyExporter();

		@SuppressWarnings("unchecked")
		final Iterator<ForeignKey> fkItr = table.getForeignKeyIterator();
		while ( fkItr.hasNext() ) {
			final ForeignKey foreignKey = fkItr.next();
			if ( foreignKey.isPhysicalConstraint() && foreignKey.isCreationEnabled() ) {
				boolean existingForeignKeyFound = false;
				if ( tableInformation != null ) {
					existingForeignKeyFound = checkForExistingForeignKey(
							foreignKey,
							tableInformation
					);
				}
				if ( !existingForeignKeyFound ) {
					// todo : shouldn't we just drop+recreate if FK exists?
					//		this follows the existing code from legacy SchemaUpdate which just skipped

					// in old SchemaUpdate code, this was the trigger to "create"
					applySqlStrings(
							false,
							exporter.getSqlCreateStrings( foreignKey, metadata ),
							formatter,
							options,
							targets
					);
				}
			}
		}
	}
}
 
Example #3
Source File: Dialect.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public Exporter<Index> getIndexExporter() {
	return indexExporter;
}
 
Example #4
Source File: DelegatingDialect.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Exporter<AuxiliaryDatabaseObject> getAuxiliaryDatabaseObjectExporter() {
    return getInstance().getAuxiliaryDatabaseObjectExporter();
}
 
Example #5
Source File: DelegatingDialect.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Exporter<Constraint> getUniqueKeyExporter() {
    return getInstance().getUniqueKeyExporter();
}
 
Example #6
Source File: DelegatingDialect.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Exporter<ForeignKey> getForeignKeyExporter() {
    return getInstance().getForeignKeyExporter();
}
 
Example #7
Source File: DelegatingDialect.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Exporter<Index> getIndexExporter() {
    return getInstance().getIndexExporter();
}
 
Example #8
Source File: DelegatingDialect.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Exporter<Sequence> getSequenceExporter() {
    return getInstance().getSequenceExporter();
}
 
Example #9
Source File: DelegatingDialect.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Exporter<Table> getTableExporter() {
    return getInstance().getTableExporter();
}
 
Example #10
Source File: Dialect.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public Exporter<AuxiliaryDatabaseObject> getAuxiliaryDatabaseObjectExporter() {
	return auxiliaryObjectExporter;
}
 
Example #11
Source File: Dialect.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public Exporter<Constraint> getUniqueKeyExporter() {
	return uniqueKeyExporter;
}
 
Example #12
Source File: Dialect.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public Exporter<ForeignKey> getForeignKeyExporter() {
	return foreignKeyExporter;
}
 
Example #13
Source File: SpannerDialect.java    From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public Exporter<Table> getTableExporter() {
  return this.spannerTableExporter;
}
 
Example #14
Source File: Dialect.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public Exporter<Sequence> getSequenceExporter() {
	return sequenceExporter;
}
 
Example #15
Source File: Dialect.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public Exporter<Table> getTableExporter() {
	return tableExporter;
}
 
Example #16
Source File: AbstractHANADialect.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Exporter<Table> getTableExporter() {
	return this.hanaTableExporter;
}
 
Example #17
Source File: Teradata14Dialect.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Exporter<Index> getIndexExporter() {
	return TeraIndexExporter;
}
 
Example #18
Source File: AbstractSchemaMigrator.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected void applyUniqueKeys(
		Table table,
		TableInformation tableInfo,
		Dialect dialect,
		Metadata metadata,
		Formatter formatter,
		ExecutionOptions options,
		GenerationTarget... targets) {
	if ( uniqueConstraintStrategy == null ) {
		uniqueConstraintStrategy = determineUniqueConstraintSchemaUpdateStrategy( metadata );
	}

	if ( uniqueConstraintStrategy != UniqueConstraintSchemaUpdateStrategy.SKIP ) {
		final Exporter<Constraint> exporter = dialect.getUniqueKeyExporter();

		final Iterator ukItr = table.getUniqueKeyIterator();
		while ( ukItr.hasNext() ) {
			final UniqueKey uniqueKey = (UniqueKey) ukItr.next();
			// Skip if index already exists. Most of the time, this
			// won't work since most Dialects use Constraints. However,
			// keep it for the few that do use Indexes.
			IndexInformation indexInfo = null;
			if ( tableInfo != null && StringHelper.isNotEmpty( uniqueKey.getName() ) ) {
				indexInfo = tableInfo.getIndex( Identifier.toIdentifier( uniqueKey.getName() ) );
			}
			if ( indexInfo == null ) {
				if ( uniqueConstraintStrategy == UniqueConstraintSchemaUpdateStrategy.DROP_RECREATE_QUIETLY ) {
					applySqlStrings(
							true,
							exporter.getSqlDropStrings( uniqueKey, metadata ),
							formatter,
							options,
							targets
					);
				}

				applySqlStrings(
						true,
						exporter.getSqlCreateStrings( uniqueKey, metadata ),
						formatter,
						options,
						targets
				);
			}
		}
	}
}
 
Example #19
Source File: SpannerDialect.java    From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public Exporter<Sequence> getSequenceExporter() {
  return NOOP_EXPORTER;
}
 
Example #20
Source File: SpannerDialect.java    From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public Exporter<ForeignKey> getForeignKeyExporter() {
  return this.spannerForeignKeyExporter;
}