prefer importing JPA annotations

This commit is contained in:
Gavin King 2022-10-28 08:29:58 +02:00
parent 9cd834758a
commit f4687ac048
7 changed files with 77 additions and 77 deletions

View File

@ -42,7 +42,6 @@ import org.hibernate.annotations.FetchProfile;
import org.hibernate.annotations.FetchProfiles; import org.hibernate.annotations.FetchProfiles;
import org.hibernate.annotations.FilterDef; import org.hibernate.annotations.FilterDef;
import org.hibernate.annotations.FilterDefs; import org.hibernate.annotations.FilterDefs;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.Formula; import org.hibernate.annotations.Formula;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.GenericGenerators; import org.hibernate.annotations.GenericGenerators;
@ -134,6 +133,7 @@ import jakarta.persistence.Embedded;
import jakarta.persistence.EmbeddedId; import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.FetchType; import jakarta.persistence.FetchType;
import jakarta.persistence.ForeignKey;
import jakarta.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import jakarta.persistence.Inheritance; import jakarta.persistence.Inheritance;
@ -2710,7 +2710,7 @@ public final class AnnotationBinder {
public static void bindForeignKeyNameAndDefinition( public static void bindForeignKeyNameAndDefinition(
SimpleValue value, SimpleValue value,
XProperty property, XProperty property,
jakarta.persistence.ForeignKey fkOverride, ForeignKey fkOverride,
JoinColumn joinColumn, JoinColumn joinColumn,
JoinColumns joinColumns, JoinColumns joinColumns,
MetadataBuildingContext context) { MetadataBuildingContext context) {
@ -2724,7 +2724,7 @@ public final class AnnotationBinder {
value.disableForeignKey(); value.disableForeignKey();
} }
else { else {
final ForeignKey fk = property.getAnnotation( ForeignKey.class ); final org.hibernate.annotations.ForeignKey fk = property.getAnnotation( org.hibernate.annotations.ForeignKey.class );
if ( fk != null && StringHelper.isNotEmpty( fk.name() ) ) { if ( fk != null && StringHelper.isNotEmpty( fk.name() ) ) {
value.setForeignKeyName( fk.name() ); value.setForeignKeyName( fk.name() );
} }
@ -2749,7 +2749,7 @@ public final class AnnotationBinder {
} }
} }
private static boolean noConstraint(jakarta.persistence.ForeignKey joinColumns, MetadataBuildingContext context) { private static boolean noConstraint(ForeignKey joinColumns, MetadataBuildingContext context) {
return joinColumns != null return joinColumns != null
&& ( joinColumns.value() == ConstraintMode.NO_CONSTRAINT && ( joinColumns.value() == ConstraintMode.NO_CONSTRAINT
|| joinColumns.value() == ConstraintMode.PROVIDER_DEFAULT || joinColumns.value() == ConstraintMode.PROVIDER_DEFAULT

View File

@ -6,11 +6,9 @@
*/ */
package org.hibernate.cfg; package org.hibernate.cfg;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import org.hibernate.MappingException; import org.hibernate.MappingException;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.mapping.Collection; import org.hibernate.mapping.Collection;
import org.hibernate.mapping.IndexedCollection; import org.hibernate.mapping.IndexedCollection;
@ -30,12 +28,10 @@ public abstract class CollectionSecondPass implements SecondPass {
private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, CollectionSecondPass.class.getName()); private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, CollectionSecondPass.class.getName());
// MetadataBuildingContext buildingContext;
private final Collection collection; private final Collection collection;
public CollectionSecondPass(MetadataBuildingContext buildingContext, Collection collection) { public CollectionSecondPass(Collection collection) {
this.collection = collection; this.collection = collection;
// this.buildingContext = buildingContext;
} }
public void doSecondPass(Map<String, PersistentClass> persistentClasses) public void doSecondPass(Map<String, PersistentClass> persistentClasses)
@ -67,10 +63,11 @@ public abstract class CollectionSecondPass implements SecondPass {
private static String columns(Value val) { private static String columns(Value val) {
StringBuilder columns = new StringBuilder(); StringBuilder columns = new StringBuilder();
Iterator<Selectable> iter = val.getColumnIterator(); for ( Selectable selectable : val.getSelectables() ) {
while ( iter.hasNext() ) { if ( columns.length() > 0 ) {
columns.append( iter.next().getText() ); columns.append( ", " );
if ( iter.hasNext() ) columns.append( ", " ); }
columns.append( selectable.getText() );
} }
return columns.toString(); return columns.toString();
} }

View File

@ -21,6 +21,8 @@ import jakarta.persistence.ConstraintMode;
import jakarta.persistence.ElementCollection; import jakarta.persistence.ElementCollection;
import jakarta.persistence.Embedded; import jakarta.persistence.Embedded;
import jakarta.persistence.FetchType; import jakarta.persistence.FetchType;
import jakarta.persistence.ForeignKey;
import jakarta.persistence.Index;
import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinColumn;
import jakarta.persistence.JoinColumns; import jakarta.persistence.JoinColumns;
import jakarta.persistence.JoinTable; import jakarta.persistence.JoinTable;
@ -30,9 +32,10 @@ import jakarta.persistence.MapKeyColumn;
import jakarta.persistence.MapKeyJoinColumn; import jakarta.persistence.MapKeyJoinColumn;
import jakarta.persistence.MapKeyJoinColumns; import jakarta.persistence.MapKeyJoinColumns;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import jakarta.persistence.OrderBy;
import jakarta.persistence.OrderColumn; import jakarta.persistence.OrderColumn;
import jakarta.persistence.UniqueConstraint; import jakarta.persistence.UniqueConstraint;
import org.hibernate.AnnotationException; import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure; import org.hibernate.AssertionFailure;
import org.hibernate.FetchMode; import org.hibernate.FetchMode;
@ -54,7 +57,6 @@ import org.hibernate.annotations.Filter;
import org.hibernate.annotations.FilterJoinTable; import org.hibernate.annotations.FilterJoinTable;
import org.hibernate.annotations.FilterJoinTables; import org.hibernate.annotations.FilterJoinTables;
import org.hibernate.annotations.Filters; import org.hibernate.annotations.Filters;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.Formula; import org.hibernate.annotations.Formula;
import org.hibernate.annotations.Immutable; import org.hibernate.annotations.Immutable;
import org.hibernate.annotations.LazyCollection; import org.hibernate.annotations.LazyCollection;
@ -76,7 +78,6 @@ import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.OnDelete; import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction; import org.hibernate.annotations.OnDeleteAction;
import org.hibernate.annotations.OptimisticLock; import org.hibernate.annotations.OptimisticLock;
import org.hibernate.annotations.OrderBy;
import org.hibernate.annotations.Parameter; import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Persister; import org.hibernate.annotations.Persister;
import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.SQLDelete;
@ -227,8 +228,8 @@ public abstract class CollectionBinder {
private AccessType accessType; private AccessType accessType;
private boolean hibernateExtensionMapping; private boolean hibernateExtensionMapping;
private jakarta.persistence.OrderBy jpaOrderBy; private OrderBy jpaOrderBy;
private OrderBy sqlOrderBy; private org.hibernate.annotations.OrderBy sqlOrderBy;
private SortNatural naturalSort; private SortNatural naturalSort;
private SortComparator comparatorSort; private SortComparator comparatorSort;
@ -290,8 +291,8 @@ public abstract class CollectionBinder {
collectionBinder.setBatchSize( property.getAnnotation( BatchSize.class ) ); collectionBinder.setBatchSize( property.getAnnotation( BatchSize.class ) );
collectionBinder.setJpaOrderBy( property.getAnnotation( jakarta.persistence.OrderBy.class ) ); collectionBinder.setJpaOrderBy( property.getAnnotation( OrderBy.class ) );
collectionBinder.setSqlOrderBy( getOverridableAnnotation( property, OrderBy.class, context ) ); collectionBinder.setSqlOrderBy( getOverridableAnnotation( property, org.hibernate.annotations.OrderBy.class, context ) );
collectionBinder.setNaturalSort( property.getAnnotation( SortNatural.class ) ); collectionBinder.setNaturalSort( property.getAnnotation( SortNatural.class ) );
collectionBinder.setComparatorSort( property.getAnnotation( SortComparator.class ) ); collectionBinder.setComparatorSort( property.getAnnotation( SortComparator.class ) );
@ -539,7 +540,7 @@ public abstract class CollectionBinder {
Comment comment) { Comment comment) {
final jakarta.persistence.Column[] keyColumns = property.isAnnotationPresent(MapKeyColumn.class) final jakarta.persistence.Column[] keyColumns = property.isAnnotationPresent(MapKeyColumn.class)
? new jakarta.persistence.Column[]{ new MapKeyColumnDelegator( property.getAnnotation(MapKeyColumn.class) ) } ? new jakarta.persistence.Column[] { new MapKeyColumnDelegator( property.getAnnotation(MapKeyColumn.class) ) }
: null; : null;
final AnnotatedColumn[] mapColumns = buildColumnsFromAnnotations( final AnnotatedColumn[] mapColumns = buildColumnsFromAnnotations(
@ -601,7 +602,7 @@ public abstract class CollectionBinder {
final UniqueConstraint[] uniqueConstraints; final UniqueConstraint[] uniqueConstraints;
final JoinColumn[] joins; final JoinColumn[] joins;
final JoinColumn[] inverseJoins; final JoinColumn[] inverseJoins;
final jakarta.persistence.Index[] jpaIndexes; final Index[] jpaIndexes;
//JPA 2 has priority //JPA 2 has priority
@ -731,7 +732,7 @@ public abstract class CollectionBinder {
this.jpaOrderBy = jpaOrderBy; this.jpaOrderBy = jpaOrderBy;
} }
public void setSqlOrderBy(OrderBy sqlOrderBy) { public void setSqlOrderBy(org.hibernate.annotations.OrderBy sqlOrderBy) {
this.sqlOrderBy = sqlOrderBy; this.sqlOrderBy = sqlOrderBy;
} }
@ -998,7 +999,7 @@ public abstract class CollectionBinder {
return CollectionClassification.LIST; return CollectionClassification.LIST;
} }
if ( property.isAnnotationPresent( jakarta.persistence.OrderBy.class ) if ( property.isAnnotationPresent( jakarta.persistence.OrderBy.class )
|| property.isAnnotationPresent( OrderBy.class ) ) { || property.isAnnotationPresent( org.hibernate.annotations.OrderBy.class ) ) {
return CollectionClassification.BAG; return CollectionClassification.BAG;
} }
ManyToMany manyToMany = property.getAnnotation( ManyToMany.class ); ManyToMany manyToMany = property.getAnnotation( ManyToMany.class );
@ -1377,7 +1378,7 @@ public abstract class CollectionBinder {
"Collection '%s' is annotated both '@%s' and '@%s'", "Collection '%s' is annotated both '@%s' and '@%s'",
safeCollectionRole(), safeCollectionRole(),
jakarta.persistence.OrderBy.class.getName(), jakarta.persistence.OrderBy.class.getName(),
OrderBy.class.getName() org.hibernate.annotations.OrderBy.class.getName()
) )
); );
} }
@ -1389,7 +1390,7 @@ public abstract class CollectionBinder {
"Collection '%s' is both sorted and ordered (only one of '@%s', '@%s', '@%s', and '@%s' may be used)", "Collection '%s' is both sorted and ordered (only one of '@%s', '@%s', '@%s', and '@%s' may be used)",
safeCollectionRole(), safeCollectionRole(),
jakarta.persistence.OrderBy.class.getName(), jakarta.persistence.OrderBy.class.getName(),
OrderBy.class.getName(), org.hibernate.annotations.OrderBy.class.getName(),
SortComparator.class.getName(), SortComparator.class.getName(),
SortNatural.class.getName() SortNatural.class.getName()
) )
@ -1497,7 +1498,7 @@ public abstract class CollectionBinder {
final boolean unique, final boolean unique,
final TableBinder assocTableBinder, final TableBinder assocTableBinder,
final MetadataBuildingContext buildingContext) { final MetadataBuildingContext buildingContext) {
return new CollectionSecondPass( buildingContext, collection ) { return new CollectionSecondPass( collection ) {
@Override @Override
public void secondPass(Map<String, PersistentClass> persistentClasses) throws MappingException { public void secondPass(Map<String, PersistentClass> persistentClasses) throws MappingException {
bindStarToManySecondPass( bindStarToManySecondPass(
@ -1922,22 +1923,9 @@ public abstract class CollectionBinder {
PropertyHolder propertyHolder, PropertyHolder propertyHolder,
MetadataBuildingContext buildingContext) { MetadataBuildingContext buildingContext) {
//give a chance to override the referenced property name // give a chance to override the referenced property name
//has to do that here because the referencedProperty creation happens in a FKSecondPass for Many to one yuk! // has to do that here because the referencedProperty creation happens in a FKSecondPass for ManyToOne yuk!
if ( joinColumns.length > 0 && isNotEmpty( joinColumns[0].getMappedBy() ) ) { overrideReferencedPropertyName( collValue, joinColumns, buildingContext );
String entityName = joinColumns[0].getManyToManyOwnerSideEntityName() != null ?
"inverse__" + joinColumns[0].getManyToManyOwnerSideEntityName() :
joinColumns[0].getPropertyHolder().getEntityName();
InFlightMetadataCollector metadataCollector = buildingContext.getMetadataCollector();
String propRef = metadataCollector.getPropertyReferencedAssociation(
entityName,
joinColumns[0].getMappedBy()
);
if ( propRef != null ) {
collValue.setReferencedPropertyName( propRef );
metadataCollector.addPropertyReference( collValue.getOwnerEntityName(), propRef );
}
}
String propRef = collValue.getReferencedPropertyName(); String propRef = collValue.getReferencedPropertyName();
//binding key reference using column //binding key reference using column
@ -1954,7 +1942,7 @@ public abstract class CollectionBinder {
collValue.setKey( key ); collValue.setKey( key );
if ( property != null ) { if ( property != null ) {
final ForeignKey fk = property.getAnnotation( ForeignKey.class ); final org.hibernate.annotations.ForeignKey fk = property.getAnnotation( org.hibernate.annotations.ForeignKey.class );
if ( fk != null && !isEmptyAnnotationValue( fk.name() ) ) { if ( fk != null && !isEmptyAnnotationValue( fk.name() ) ) {
key.setForeignKeyName( fk.name() ); key.setForeignKeyName( fk.name() );
} }
@ -2003,16 +1991,17 @@ public abstract class CollectionBinder {
} }
} }
else { else {
final jakarta.persistence.ForeignKey fkOverride = propertyHolder.getOverriddenForeignKey( final String propertyPath = qualify(propertyHolder.getPath(), property.getName());
qualify( propertyHolder.getPath(), property.getName() ) final ForeignKey foreignKey = propertyHolder.getOverriddenForeignKey( propertyPath );
); if ( foreignKey != null ) {
if ( fkOverride != null && ( fkOverride.value() == ConstraintMode.NO_CONSTRAINT || if ( foreignKey.value() == ConstraintMode.NO_CONSTRAINT
fkOverride.value() == ConstraintMode.PROVIDER_DEFAULT && noConstraintByDefault ) ) { || foreignKey.value() == ConstraintMode.PROVIDER_DEFAULT && noConstraintByDefault ) {
key.disableForeignKey(); key.disableForeignKey();
} }
else if ( fkOverride != null ) { else {
key.setForeignKeyName( nullIfEmpty( fkOverride.name() ) ); key.setForeignKeyName( nullIfEmpty( foreignKey.name() ) );
key.setForeignKeyDefinition( nullIfEmpty( fkOverride.foreignKeyDefinition() ) ); key.setForeignKeyDefinition( nullIfEmpty( foreignKey.foreignKeyDefinition() ) );
}
} }
else { else {
final OneToMany oneToManyAnn = property.getAnnotation( OneToMany.class ); final OneToMany oneToManyAnn = property.getAnnotation( OneToMany.class );
@ -2045,6 +2034,26 @@ public abstract class CollectionBinder {
return key; return key;
} }
private static void overrideReferencedPropertyName(
Collection collValue,
AnnotatedJoinColumn[] joinColumns,
MetadataBuildingContext buildingContext) {
if ( joinColumns.length > 0 ) {
AnnotatedJoinColumn joinColumn = joinColumns[0];
if (isNotEmpty( joinColumn.getMappedBy() )) {
String entityName = joinColumn.getManyToManyOwnerSideEntityName() != null
? "inverse__" + joinColumn.getManyToManyOwnerSideEntityName()
: joinColumn.getPropertyHolder().getEntityName();
InFlightMetadataCollector metadataCollector = buildingContext.getMetadataCollector();
String propRef = metadataCollector.getPropertyReferencedAssociation( entityName, joinColumn.getMappedBy() );
if ( propRef != null ) {
collValue.setReferencedPropertyName( propRef );
metadataCollector.addPropertyReference( collValue.getOwnerEntityName(), propRef );
}
}
}
}
private void bindManyToManySecondPass( private void bindManyToManySecondPass(
Collection collValue, Collection collValue,
Map<String, PersistentClass> persistentClasses, Map<String, PersistentClass> persistentClasses,
@ -2074,8 +2083,6 @@ public abstract class CollectionBinder {
logManyToManySecondPass( collValue, joinColumns, unique, isCollectionOfEntities, isManyToAny ); logManyToManySecondPass( collValue, joinColumns, unique, isCollectionOfEntities, isManyToAny );
//check for user error //check for user error
detectManyToManyProblems( detectManyToManyProblems(
collValue,
joinColumns,
elementType, elementType,
property, property,
parentPropertyHolder, parentPropertyHolder,
@ -2335,7 +2342,7 @@ public abstract class CollectionBinder {
collValue.setManyToManyOrdering( buildOrderByClauseFromHql( hqlOrderBy, collectionEntity ) ); collValue.setManyToManyOrdering( buildOrderByClauseFromHql( hqlOrderBy, collectionEntity ) );
} }
final ForeignKey fk = property.getAnnotation( ForeignKey.class ); final org.hibernate.annotations.ForeignKey fk = property.getAnnotation( org.hibernate.annotations.ForeignKey.class );
if ( fk != null && !isEmptyAnnotationValue( fk.name() ) ) { if ( fk != null && !isEmptyAnnotationValue( fk.name() ) ) {
element.setForeignKeyName( fk.name() ); element.setForeignKeyName( fk.name() );
} }
@ -2509,8 +2516,6 @@ public abstract class CollectionBinder {
} }
private void detectManyToManyProblems( private void detectManyToManyProblems(
Collection collValue,
AnnotatedJoinColumn[] joinColumns,
XClass elementType, XClass elementType,
XProperty property, XProperty property,
PropertyHolder parentPropertyHolder, PropertyHolder parentPropertyHolder,
@ -2608,7 +2613,7 @@ public abstract class CollectionBinder {
return null; return null;
} }
private String extractHqlOrderBy(jakarta.persistence.OrderBy jpaOrderBy) { private String extractHqlOrderBy(OrderBy jpaOrderBy) {
if ( jpaOrderBy != null ) { if ( jpaOrderBy != null ) {
return jpaOrderBy.value(); // Null not possible. In case of empty expression, apply default ordering. return jpaOrderBy.value(); // Null not possible. In case of empty expression, apply default ordering.
} }

View File

@ -808,15 +808,12 @@ public class EntityBinder {
EntityBinder entityBinder) { EntityBinder entityBinder) {
final boolean isRoot = !inheritanceState.hasParents(); final boolean isRoot = !inheritanceState.hasParents();
AnnotatedDiscriminatorColumn discriminatorColumn = null; DiscriminatorColumn discAnn = clazzToProcess.getAnnotation( DiscriminatorColumn.class );
jakarta.persistence.DiscriminatorColumn discAnn = clazzToProcess.getAnnotation( DiscriminatorType discriminatorType = discAnn != null ? discAnn.discriminatorType() : DiscriminatorType.STRING;
jakarta.persistence.DiscriminatorColumn.class
);
DiscriminatorType discriminatorType = discAnn != null
? discAnn.discriminatorType()
: DiscriminatorType.STRING;
DiscriminatorFormula discFormulaAnn = getOverridableAnnotation( clazzToProcess, DiscriminatorFormula.class, context ); DiscriminatorFormula discFormulaAnn = getOverridableAnnotation( clazzToProcess, DiscriminatorFormula.class, context );
AnnotatedDiscriminatorColumn discriminatorColumn = null;
if ( isRoot ) { if ( isRoot ) {
discriminatorColumn = buildDiscriminatorColumn( discriminatorColumn = buildDiscriminatorColumn(
discriminatorType, discriminatorType,

View File

@ -77,7 +77,7 @@ public class ListBinder extends CollectionBinder {
final boolean unique, final boolean unique,
final TableBinder assocTableBinder, final TableBinder assocTableBinder,
final MetadataBuildingContext buildingContext) { final MetadataBuildingContext buildingContext) {
return new CollectionSecondPass( getBuildingContext(), ListBinder.this.collection ) { return new CollectionSecondPass( ListBinder.this.collection ) {
@Override @Override
public void secondPass(Map<String, PersistentClass> persistentClasses) public void secondPass(Map<String, PersistentClass> persistentClasses)
throws MappingException { throws MappingException {

View File

@ -103,7 +103,7 @@ public class MapBinder extends CollectionBinder {
final boolean unique, final boolean unique,
final TableBinder assocTableBinder, final TableBinder assocTableBinder,
final MetadataBuildingContext buildingContext) { final MetadataBuildingContext buildingContext) {
return new CollectionSecondPass( buildingContext, MapBinder.this.collection ) { return new CollectionSecondPass( MapBinder.this.collection ) {
public void secondPass(Map<String, PersistentClass> persistentClasses) public void secondPass(Map<String, PersistentClass> persistentClasses)
throws MappingException { throws MappingException {
bindStarToManySecondPass( bindStarToManySecondPass(

View File

@ -8,11 +8,12 @@ package org.hibernate.cfg.annotations;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import jakarta.persistence.Index;
import jakarta.persistence.UniqueConstraint; import jakarta.persistence.UniqueConstraint;
import org.hibernate.AnnotationException; import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure; import org.hibernate.AssertionFailure;
import org.hibernate.annotations.Index;
import org.hibernate.boot.model.naming.EntityNaming; import org.hibernate.boot.model.naming.EntityNaming;
import org.hibernate.boot.model.naming.Identifier; import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.naming.ImplicitCollectionTableNameSource; import org.hibernate.boot.model.naming.ImplicitCollectionTableNameSource;
@ -114,7 +115,7 @@ public class TableBinder {
this.uniqueConstraints = TableBinder.buildUniqueConstraintHolders( uniqueConstraints ); this.uniqueConstraints = TableBinder.buildUniqueConstraintHolders( uniqueConstraints );
} }
public void setJpaIndex(jakarta.persistence.Index[] jpaIndex){ public void setJpaIndex(Index[] jpaIndex){
this.jpaIndexHolders = buildJpaIndexHolder( jpaIndex ); this.jpaIndexHolders = buildJpaIndexHolder( jpaIndex );
} }
@ -757,8 +758,8 @@ public class TableBinder {
} }
} }
public static void addIndexes(Table hibTable, Index[] indexes, MetadataBuildingContext buildingContext) { public static void addIndexes(Table hibTable, org.hibernate.annotations.Index[] indexes, MetadataBuildingContext buildingContext) {
for (Index index : indexes) { for ( org.hibernate.annotations.Index index : indexes ) {
//no need to handle inSecondPass here since it is only called from EntityBinder //no need to handle inSecondPass here since it is only called from EntityBinder
buildingContext.getMetadataCollector().addSecondPass( buildingContext.getMetadataCollector().addSecondPass(
new IndexOrUniqueKeySecondPass( hibTable, index.name(), index.columnNames(), buildingContext ) new IndexOrUniqueKeySecondPass( hibTable, index.name(), index.columnNames(), buildingContext )
@ -766,13 +767,13 @@ public class TableBinder {
} }
} }
public static void addIndexes(Table hibTable, jakarta.persistence.Index[] indexes, MetadataBuildingContext buildingContext) { public static void addIndexes(Table hibTable, Index[] indexes, MetadataBuildingContext buildingContext) {
buildingContext.getMetadataCollector().addJpaIndexHolders( hibTable, buildJpaIndexHolder( indexes ) ); buildingContext.getMetadataCollector().addJpaIndexHolders( hibTable, buildJpaIndexHolder( indexes ) );
} }
public static List<JPAIndexHolder> buildJpaIndexHolder(jakarta.persistence.Index[] indexes){ public static List<JPAIndexHolder> buildJpaIndexHolder(Index[] indexes){
List<JPAIndexHolder> holders = new ArrayList<>( indexes.length ); List<JPAIndexHolder> holders = new ArrayList<>( indexes.length );
for(jakarta.persistence.Index index : indexes){ for ( Index index : indexes ) {
holders.add( new JPAIndexHolder( index ) ); holders.add( new JPAIndexHolder( index ) );
} }
return holders; return holders;