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 committed Jul 3, 2023
1 parent 27f42fc commit c1d1c50
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions orm6/mapper/orm/ant-src-changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -908,33 +908,47 @@ index 4fd6258ed4..eaac4243ea 100644
HibernateOrmEntityLoadingStrategy<? super E, ?> loadingStrategy();

diff --git a/main/java/org/hibernate/search/mapper/orm/loading/impl/MutableEntityLoadingOptions.java b/main/java/org/hibernate/search/mapper/orm/loading/impl/MutableEntityLoadingOptions.java
index a8669bf79d..838d51df7b 100644
index a8669bf79d..48e2214a60 100644
--- a/main/java/org/hibernate/search/mapper/orm/loading/impl/MutableEntityLoadingOptions.java
+++ b/main/java/org/hibernate/search/mapper/orm/loading/impl/MutableEntityLoadingOptions.java
@@ -9,7 +9,7 @@
@@ -9,7 +9,8 @@
import java.util.ArrayList;
import java.util.List;

-import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.metamodel.mapping.EntityMappingType;
+import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.search.util.common.impl.Contracts;

public class MutableEntityLoadingOptions {
@@ -30,11 +30,11 @@ public void fetchSize(int fetchSize) {
@@ -30,15 +31,20 @@ public void fetchSize(int fetchSize) {
this.fetchSize = fetchSize;
}

- public EntityGraphHint<?> entityGraphHintOrNullForType(EntityPersister entityPersister) {
- if ( entityGraphHints == null ) {
+ public EntityGraphHint<?> entityGraphHintOrNullForType(EntityMappingType entityMappingType) {
if ( entityGraphHints == null ) {
+ if ( entityGraphHints == null || entityGraphHints.isEmpty() ) {
return null;
}
- String hibernateOrmEntityName = entityPersister.getEntityName();
+ String hibernateOrmEntityName = entityMappingType.getEntityName();
for ( EntityGraphHint<?> entityGraphHint : entityGraphHints ) {
if ( entityGraphHint.graph.appliesTo( hibernateOrmEntityName ) ) {
return entityGraphHint;
@@ -50,6 +50,9 @@ public void entityGraphHint(EntityGraphHint<?> entityGraphHint, boolean replaceE
- 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;
}
@@ -50,6 +56,9 @@ public void entityGraphHint(EntityGraphHint<?> entityGraphHint, boolean replaceE
else if ( replaceExisting ) {
entityGraphHints.clear();
}
Expand Down

0 comments on commit c1d1c50

Please sign in to comment.