Java Code Examples for org.hibernate.mapping.Table#getIndexIterator()

The following examples show how to use org.hibernate.mapping.Table#getIndexIterator() . 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: SpannerTableStatements.java    From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Set<String> getTableIndices(Table table) {
  Set<String> tableIndices = new HashSet<>();

  Iterator<Index> indexIterator = table.getIndexIterator();
  while (indexIterator.hasNext()) {
    tableIndices.add(indexIterator.next().getName());
  }

  Iterator<UniqueKey> keyIterator = table.getUniqueKeyIterator();
  while (keyIterator.hasNext()) {
    tableIndices.add(keyIterator.next().getName());
  }

  return tableIndices;
}
 
Example 2
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 3
Source File: IgniteCacheInitializer.java    From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Create indexes for {@code @Index} annotations
 * @param queryEntity
 * @param context
 */
private void addUserIndexes(QueryEntity queryEntity, SchemaDefinitionContext context, String tableName) {
	Namespace namespace = context.getDatabase().getDefaultNamespace();
	Optional<Table> tableOptional = namespace.getTables().stream().filter( currentTable -> currentTable.getName().equals( tableName ) ).findFirst();
	if ( tableOptional.isPresent() ) {
		Table table = tableOptional.get();
		for ( Iterator<Index> indexIterator = table.getIndexIterator(); indexIterator.hasNext(); ) {
			Index index = indexIterator.next();
			appendIndex( queryEntity, index, context );
		}
	}
}