Skip to content

Commit

Permalink
HSEARCH-4890 Adapt calls to RootGraph#appliesTo() to Hibernate ORM 6.3
Browse files Browse the repository at this point in the history
  • Loading branch information
yrodiere authored and marko-bekhta committed Sep 25, 2023
1 parent 0a0b454 commit 737eb09
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.List;

import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.search.util.common.impl.Contracts;

public class MutableEntityLoadingOptions {
Expand All @@ -31,14 +32,19 @@ public void fetchSize(int fetchSize) {
}

public EntityGraphHint<?> entityGraphHintOrNullForType(EntityMappingType entityMappingType) {
if ( entityGraphHints == null ) {
if ( entityGraphHints == null || entityGraphHints.isEmpty() ) {
return null;
}
String hibernateOrmEntityName = entityMappingType.getEntityName();
for ( EntityGraphHint<?> entityGraphHint : entityGraphHints ) {
if ( entityGraphHint.graph.appliesTo( hibernateOrmEntityName ) ) {
return entityGraphHint;
EntityMappingType testedType = entityMappingType;
while ( testedType != null ) {
for ( EntityGraphHint<?> entityGraphHint : entityGraphHints ) {
// This cast is fine because a RootGraph always applies to an entity type
EntityDomainType<?> graphedType = (EntityDomainType<?>) entityGraphHint.graph.getGraphedType();
if ( graphedType.getHibernateEntityName().equals( testedType.getEntityName() ) ) {
return entityGraphHint;
}
}
testedType = testedType.getSuperMappingType();
}
return null;
}
Expand Down

0 comments on commit 737eb09

Please sign in to comment.