Java Code Examples for org.hibernate.mapping.Index#getColumnIterator()
The following examples show how to use
org.hibernate.mapping.Index#getColumnIterator() .
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: IgniteCacheInitializer.java From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 | 5 votes |
private void appendIndex(QueryEntity queryEntity, Index index, SchemaDefinitionContext context) { QueryIndex queryIndex = new QueryIndex(); queryIndex.setName( index.getName() ); queryIndex.setIndexType( QueryIndexType.SORTED ); LinkedHashMap<String, Boolean> fields = new LinkedHashMap<>(); for ( Iterator<Column> columnIterator = index.getColumnIterator(); columnIterator.hasNext(); ) { Column currentColumn = columnIterator.next(); fields.put( currentColumn.getName(), true ); } queryIndex.setFields( fields ); Set<QueryIndex> indexes = new HashSet<>( queryEntity.getIndexes() ); indexes.add( queryIndex ); queryEntity.setIndexes( indexes ); }
Example 2
Source File: StandardIndexExporter.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public String[] getSqlCreateStrings(Index index, Metadata metadata) { final JdbcEnvironment jdbcEnvironment = metadata.getDatabase().getJdbcEnvironment(); final String tableName = jdbcEnvironment.getQualifiedObjectNameFormatter().format( index.getTable().getQualifiedTableName(), dialect ); final String indexNameForCreation; if ( dialect.qualifyIndexName() ) { indexNameForCreation = jdbcEnvironment.getQualifiedObjectNameFormatter().format( new QualifiedNameImpl( index.getTable().getQualifiedTableName().getCatalogName(), index.getTable().getQualifiedTableName().getSchemaName(), jdbcEnvironment.getIdentifierHelper().toIdentifier( index.getQuotedName( dialect ) ) ), jdbcEnvironment.getDialect() ); } else { indexNameForCreation = index.getName(); } final StringBuilder buf = new StringBuilder() .append( "create index " ) .append( indexNameForCreation ) .append( " on " ) .append( tableName ) .append( " (" ); boolean first = true; final Iterator<Column> columnItr = index.getColumnIterator(); final Map<Column, String> columnOrderMap = index.getColumnOrderMap(); while ( columnItr.hasNext() ) { final Column column = columnItr.next(); if ( first ) { first = false; } else { buf.append( ", " ); } buf.append( ( column.getQuotedName( dialect ) ) ); if ( columnOrderMap.containsKey( column ) ) { buf.append( " " ).append( columnOrderMap.get( column ) ); } } buf.append( ")" ); return new String[] { buf.toString() }; }
Example 3
Source File: Teradata14Dialect.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public String[] getSqlCreateStrings(Index index, Metadata metadata) { final JdbcEnvironment jdbcEnvironment = metadata.getDatabase().getJdbcEnvironment(); final String tableName = jdbcEnvironment.getQualifiedObjectNameFormatter().format( index.getTable().getQualifiedTableName(), jdbcEnvironment.getDialect() ); final String indexNameForCreation; if ( getDialect().qualifyIndexName() ) { indexNameForCreation = jdbcEnvironment.getQualifiedObjectNameFormatter().format( new QualifiedNameImpl( index.getTable().getQualifiedTableName().getCatalogName(), index.getTable().getQualifiedTableName().getSchemaName(), jdbcEnvironment.getIdentifierHelper().toIdentifier( index.getName() ) ), jdbcEnvironment.getDialect() ); } else { indexNameForCreation = index.getName(); } StringBuilder colBuf = new StringBuilder(""); boolean first = true; Iterator<Column> columnItr = index.getColumnIterator(); while ( columnItr.hasNext() ) { final Column column = columnItr.next(); if ( first ) { first = false; } else { colBuf.append( ", " ); } colBuf.append( ( column.getQuotedName( jdbcEnvironment.getDialect() )) ); } colBuf.append( ")" ); final StringBuilder buf = new StringBuilder() .append( "create index " ) .append( indexNameForCreation ) .append( "(" + colBuf ) .append( " on " ) .append( tableName ); return new String[] { buf.toString() }; }