I investigated the issue and it seems like Denis is right. From looking at the class Index
from the current hibernate implementation (cf. 1), it becomes clear that specification of index types is not supported, yet.
public static String buildSqlCreateIndexString(
Dialect dialect,
String name,
Table table,
Iterator<Column> columns,
java.util.Map<Column, String> columnOrderMap,
boolean unique,
String defaultCatalog,
String defaultSchema
) {
StringBuilder buf = new StringBuilder( "create" )
.append( unique ?
" unique" :
"" )
.append( " index " )
.append( dialect.qualifyIndexName() ?
name :
StringHelper.unqualify( name ) )
.append( " on " )
.append( table.getQualifiedName( dialect, defaultCatalog, defaultSchema ) )
.append( " (" );
while ( columns.hasNext() ) {
Column column = columns.next();
buf.append( column.getQuotedName( dialect ) );
if ( columnOrderMap.containsKey( column ) ) {
buf.append( " " ).append( columnOrderMap.get( column ) );
}
if ( columns.hasNext() ) buf.append( ", " );
}
buf.append( ")" );
return buf.toString();
}
The most simple workaround is to call session.createSQLQuery()
and to issue CREATE INDEX
yourself. This however, is a database-specific operation that needs to be maintained by the applications developer (in case the database is changed).