3131import static java .util .Collections .emptyList ;
3232import static org .hibernate .boot .model .naming .Identifier .toIdentifier ;
3333import static org .hibernate .internal .util .StringHelper .isEmpty ;
34+ import static org .hibernate .internal .util .StringHelper .isNotEmpty ;
3435import static org .hibernate .internal .util .collections .CollectionHelper .arrayList ;
3536
3637/**
@@ -160,6 +161,8 @@ private void createIndexOrUniqueKey(
160161 String [] orderings ,
161162 boolean unique ,
162163 boolean declaredAsIndex ,
164+ String type ,
165+ String using ,
163166 String options ,
164167 Selectable [] columns ) {
165168 final var source =
@@ -171,7 +174,8 @@ private void createIndexOrUniqueKey(
171174 }
172175 }
173176 final var dialect = getDialect ();
174- if ( unique && !hasFormula && dialect .supportsUniqueConstraints () ) {
177+ if ( unique && !hasFormula && dialect .supportsUniqueConstraints ()
178+ && isEmpty ( type ) && isEmpty ( using ) ) {
175179 final String keyName = getImplicitNamingStrategy ().determineUniqueKeyName ( source ).render ( dialect );
176180 final UniqueKey uniqueKey = table .getOrCreateUniqueKey ( keyName );
177181 uniqueKey .setExplicit ( true );
@@ -190,6 +194,12 @@ private void createIndexOrUniqueKey(
190194 final String keyName = getImplicitNamingStrategy ().determineIndexName ( source ).render ( dialect );
191195 final Index index = table .getOrCreateIndex ( keyName );
192196 index .setUnique ( unique );
197+ if ( isNotEmpty ( type ) ) {
198+ index .setType ( type );
199+ }
200+ if ( isNotEmpty ( using ) ) {
201+ index .setUsing ( using );
202+ }
193203 index .setOptions ( options );
194204 for ( int i = 0 ; i < columns .length ; i ++ ) {
195205 index .addColumn ( columns [i ], orderings != null ? orderings [i ] : null );
@@ -212,6 +222,8 @@ void bindIndexes(Table table, jakarta.persistence.Index[] indexes) {
212222 initializeColumns ( columnExpressions , ordering , parsed );
213223 final String name = index .name ();
214224 final boolean unique = index .unique ();
225+ final String type = index .type ();
226+ final String using = index .using ();
215227 final String options = index .options ();
216228 createIndexOrUniqueKey (
217229 table ,
@@ -221,6 +233,8 @@ void bindIndexes(Table table, jakarta.persistence.Index[] indexes) {
221233 ordering ,
222234 unique ,
223235 true ,
236+ type ,
237+ using ,
224238 options ,
225239 selectables ( table , name , columnExpressions )
226240 );
@@ -240,6 +254,8 @@ void bindUniqueConstraints(Table table, UniqueConstraint[] constraints) {
240254 null ,
241255 true ,
242256 false ,
257+ null ,
258+ null ,
243259 options ,
244260 columns ( table , name , columnNames )
245261 );
0 commit comments