Skip to content

Commit 27c0e8b

Browse files
committed
XxxxLoadAccess APIs should accept EntityGraph, not only RootGraph
1 parent 833574a commit 27c0e8b

11 files changed

+47
-36
lines changed

hibernate-core/src/main/java/org/hibernate/IdentifierLoadAccess.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77
import java.util.Optional;
88

9+
import jakarta.persistence.EntityGraph;
10+
911
import org.hibernate.graph.GraphSemantic;
10-
import org.hibernate.graph.RootGraph;
1112

1213
/**
1314
* Loads an entity by its primary identifier.
@@ -76,7 +77,7 @@ public interface IdentifierLoadAccess<T> {
7677
*
7778
* @since 6.3
7879
*/
79-
default IdentifierLoadAccess<T> withFetchGraph(RootGraph<T> graph) {
80+
default IdentifierLoadAccess<T> withFetchGraph(EntityGraph<T> graph) {
8081
return with( graph, GraphSemantic.FETCH );
8182
}
8283

@@ -87,15 +88,15 @@ default IdentifierLoadAccess<T> withFetchGraph(RootGraph<T> graph) {
8788
*
8889
* @since 6.3
8990
*/
90-
default IdentifierLoadAccess<T> withLoadGraph(RootGraph<T> graph) {
91+
default IdentifierLoadAccess<T> withLoadGraph(EntityGraph<T> graph) {
9192
return with( graph, GraphSemantic.LOAD );
9293
}
9394

9495
/**
9596
* @deprecated use {@link #withLoadGraph}
9697
*/
9798
@Deprecated(since = "6.3")
98-
default IdentifierLoadAccess<T> with(RootGraph<T> graph) {
99+
default IdentifierLoadAccess<T> with(EntityGraph<T> graph) {
99100
return withLoadGraph( graph );
100101
}
101102

@@ -104,7 +105,7 @@ default IdentifierLoadAccess<T> with(RootGraph<T> graph) {
104105
* {@linkplain jakarta.persistence.EntityGraph entity graph},
105106
* and how it should be {@linkplain GraphSemantic interpreted}.
106107
*/
107-
IdentifierLoadAccess<T> with(RootGraph<T> graph, GraphSemantic semantic);
108+
IdentifierLoadAccess<T> with(EntityGraph<T> graph, GraphSemantic semantic);
108109

109110
/**
110111
* Customize the associations fetched by specifying a

hibernate-core/src/main/java/org/hibernate/MultiIdentifierLoadAccess.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77
import java.util.List;
88

9+
import jakarta.persistence.EntityGraph;
10+
911
import org.hibernate.graph.GraphSemantic;
10-
import org.hibernate.graph.RootGraph;
1112

1213
/**
1314
* Loads multiple instances of a given entity type at once, by
@@ -65,7 +66,7 @@ public interface MultiIdentifierLoadAccess<T> {
6566
*
6667
* @since 6.3
6768
*/
68-
default MultiIdentifierLoadAccess<T> withFetchGraph(RootGraph<T> graph) {
69+
default MultiIdentifierLoadAccess<T> withFetchGraph(EntityGraph<T> graph) {
6970
return with( graph, GraphSemantic.FETCH );
7071
}
7172

@@ -76,15 +77,15 @@ default MultiIdentifierLoadAccess<T> withFetchGraph(RootGraph<T> graph) {
7677
*
7778
* @since 6.3
7879
*/
79-
default MultiIdentifierLoadAccess<T> withLoadGraph(RootGraph<T> graph) {
80+
default MultiIdentifierLoadAccess<T> withLoadGraph(EntityGraph<T> graph) {
8081
return with( graph, GraphSemantic.LOAD );
8182
}
8283

8384
/**
8485
* @deprecated use {@link #withLoadGraph}
8586
*/
8687
@Deprecated(since = "6.3")
87-
default MultiIdentifierLoadAccess<T> with(RootGraph<T> graph) {
88+
default MultiIdentifierLoadAccess<T> with(EntityGraph<T> graph) {
8889
return with( graph, GraphSemantic.LOAD );
8990
}
9091

@@ -93,7 +94,7 @@ default MultiIdentifierLoadAccess<T> with(RootGraph<T> graph) {
9394
* {@linkplain jakarta.persistence.EntityGraph entity graph},
9495
* and how it should be {@linkplain GraphSemantic interpreted}.
9596
*/
96-
MultiIdentifierLoadAccess<T> with(RootGraph<T> graph, GraphSemantic semantic);
97+
MultiIdentifierLoadAccess<T> with(EntityGraph<T> graph, GraphSemantic semantic);
9798

9899
/**
99100
* Customize the associations fetched by specifying a

hibernate-core/src/main/java/org/hibernate/NaturalIdLoadAccess.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
*/
55
package org.hibernate;
66

7+
import jakarta.persistence.EntityGraph;
8+
79
import jakarta.persistence.metamodel.SingularAttribute;
810
import org.hibernate.graph.GraphSemantic;
9-
import org.hibernate.graph.RootGraph;
1011

1112
import java.util.Map;
1213
import java.util.Optional;
@@ -51,7 +52,7 @@ public interface NaturalIdLoadAccess<T> {
5152
*
5253
* @since 6.3
5354
*/
54-
default NaturalIdLoadAccess<T> withFetchGraph(RootGraph<T> graph) {
55+
default NaturalIdLoadAccess<T> withFetchGraph(EntityGraph<T> graph) {
5556
return with( graph, GraphSemantic.FETCH );
5657
}
5758

@@ -62,7 +63,7 @@ default NaturalIdLoadAccess<T> withFetchGraph(RootGraph<T> graph) {
6263
*
6364
* @since 6.3
6465
*/
65-
default NaturalIdLoadAccess<T> withLoadGraph(RootGraph<T> graph) {
66+
default NaturalIdLoadAccess<T> withLoadGraph(EntityGraph<T> graph) {
6667
return with( graph, GraphSemantic.LOAD );
6768
}
6869

@@ -73,7 +74,7 @@ default NaturalIdLoadAccess<T> withLoadGraph(RootGraph<T> graph) {
7374
*
7475
* @since 6.3
7576
*/
76-
NaturalIdLoadAccess<T> with(RootGraph<T> graph, GraphSemantic semantic);
77+
NaturalIdLoadAccess<T> with(EntityGraph<T> graph, GraphSemantic semantic);
7778

7879
/**
7980
* Customize the associations fetched by specifying a

hibernate-core/src/main/java/org/hibernate/NaturalIdMultiLoadAccess.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
*/
55
package org.hibernate;
66

7+
import jakarta.persistence.EntityGraph;
8+
79
import org.hibernate.graph.GraphSemantic;
8-
import org.hibernate.graph.RootGraph;
910

1011
import java.util.List;
1112

@@ -61,7 +62,7 @@ public interface NaturalIdMultiLoadAccess<T> {
6162
*
6263
* @since 6.3
6364
*/
64-
default NaturalIdMultiLoadAccess<T> withFetchGraph(RootGraph<T> graph) {
65+
default NaturalIdMultiLoadAccess<T> withFetchGraph(EntityGraph<T> graph) {
6566
return with( graph, GraphSemantic.FETCH );
6667
}
6768

@@ -72,15 +73,15 @@ default NaturalIdMultiLoadAccess<T> withFetchGraph(RootGraph<T> graph) {
7273
*
7374
* @since 6.3
7475
*/
75-
default NaturalIdMultiLoadAccess<T> withLoadGraph(RootGraph<T> graph) {
76+
default NaturalIdMultiLoadAccess<T> withLoadGraph(EntityGraph<T> graph) {
7677
return with( graph, GraphSemantic.LOAD );
7778
}
7879

7980
/**
8081
* @deprecated use {@link #withLoadGraph}
8182
*/
8283
@Deprecated(since = "6.3")
83-
default NaturalIdMultiLoadAccess<T> with(RootGraph<T> graph) {
84+
default NaturalIdMultiLoadAccess<T> with(EntityGraph<T> graph) {
8485
return with( graph, GraphSemantic.LOAD );
8586
}
8687

@@ -89,7 +90,7 @@ default NaturalIdMultiLoadAccess<T> with(RootGraph<T> graph) {
8990
* {@linkplain jakarta.persistence.EntityGraph entity graph},
9091
* and how it should be {@linkplain GraphSemantic interpreted}.
9192
*/
92-
NaturalIdMultiLoadAccess<T> with(RootGraph<T> graph, GraphSemantic semantic);
93+
NaturalIdMultiLoadAccess<T> with(EntityGraph<T> graph, GraphSemantic semantic);
9394

9495
/**
9596
* Specify a batch size, that is, how many entities should be

hibernate-core/src/main/java/org/hibernate/SimpleNaturalIdLoadAccess.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
*/
55
package org.hibernate;
66

7+
import jakarta.persistence.EntityGraph;
8+
79
import org.hibernate.graph.GraphSemantic;
8-
import org.hibernate.graph.RootGraph;
910

1011
import java.util.Optional;
1112

@@ -45,7 +46,7 @@ public interface SimpleNaturalIdLoadAccess<T> {
4546
*
4647
* @since 6.3
4748
*/
48-
default SimpleNaturalIdLoadAccess<T> withFetchGraph(RootGraph<T> graph) {
49+
default SimpleNaturalIdLoadAccess<T> withFetchGraph(EntityGraph<T> graph) {
4950
return with( graph, GraphSemantic.FETCH );
5051
}
5152

@@ -56,7 +57,7 @@ default SimpleNaturalIdLoadAccess<T> withFetchGraph(RootGraph<T> graph) {
5657
*
5758
* @since 6.3
5859
*/
59-
default SimpleNaturalIdLoadAccess<T> withLoadGraph(RootGraph<T> graph) {
60+
default SimpleNaturalIdLoadAccess<T> withLoadGraph(EntityGraph<T> graph) {
6061
return with( graph, GraphSemantic.LOAD );
6162
}
6263

@@ -67,7 +68,7 @@ default SimpleNaturalIdLoadAccess<T> withLoadGraph(RootGraph<T> graph) {
6768
*
6869
* @since 6.3
6970
*/
70-
SimpleNaturalIdLoadAccess<T> with(RootGraph<T> graph, GraphSemantic semantic);
71+
SimpleNaturalIdLoadAccess<T> with(EntityGraph<T> graph, GraphSemantic semantic);
7172

7273
/**
7374
* Customize the associations fetched by specifying a

hibernate-core/src/main/java/org/hibernate/internal/MultiIdentifierLoadAccessImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import java.util.Set;
1010
import java.util.function.Supplier;
1111

12+
import jakarta.persistence.EntityGraph;
13+
1214
import org.hibernate.CacheMode;
1315
import org.hibernate.LockOptions;
1416
import org.hibernate.MultiIdentifierLoadAccess;
@@ -18,7 +20,6 @@
1820
import org.hibernate.engine.spi.SessionImplementor;
1921
import org.hibernate.engine.spi.SharedSessionContractImplementor;
2022
import org.hibernate.graph.GraphSemantic;
21-
import org.hibernate.graph.RootGraph;
2223
import org.hibernate.graph.spi.RootGraphImplementor;
2324
import org.hibernate.persister.entity.EntityPersister;
2425
import org.hibernate.loader.ast.spi.MultiIdLoadOptions;
@@ -76,7 +77,7 @@ public MultiIdentifierLoadAccess<T> withReadOnly(boolean readOnly) {
7677
}
7778

7879
@Override
79-
public MultiIdentifierLoadAccess<T> with(RootGraph<T> graph, GraphSemantic semantic) {
80+
public MultiIdentifierLoadAccess<T> with(EntityGraph<T> graph, GraphSemantic semantic) {
8081
this.rootGraph = (RootGraphImplementor<T>) graph;
8182
this.graphSemantic = semantic;
8283
return this;

hibernate-core/src/main/java/org/hibernate/internal/NaturalIdMultiLoadAccessStandard.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66

77
import java.util.List;
88

9+
import jakarta.persistence.EntityGraph;
10+
911
import org.hibernate.CacheMode;
1012
import org.hibernate.LockOptions;
1113
import org.hibernate.NaturalIdMultiLoadAccess;
1214
import org.hibernate.engine.spi.EffectiveEntityGraph;
1315
import org.hibernate.engine.spi.LoadQueryInfluencers;
1416
import org.hibernate.engine.spi.SharedSessionContractImplementor;
1517
import org.hibernate.graph.GraphSemantic;
16-
import org.hibernate.graph.RootGraph;
1718
import org.hibernate.graph.spi.RootGraphImplementor;
1819
import org.hibernate.loader.ast.spi.MultiNaturalIdLoadOptions;
1920
import org.hibernate.persister.entity.EntityPersister;
@@ -55,7 +56,7 @@ public NaturalIdMultiLoadAccess<T> with(CacheMode cacheMode) {
5556
}
5657

5758
@Override
58-
public NaturalIdMultiLoadAccess<T> with(RootGraph<T> graph, GraphSemantic semantic) {
59+
public NaturalIdMultiLoadAccess<T> with(EntityGraph<T> graph, GraphSemantic semantic) {
5960
this.rootGraph = (RootGraphImplementor<T>) graph;
6061
this.graphSemantic = semantic;
6162
return this;

hibernate-core/src/main/java/org/hibernate/loader/internal/BaseNaturalIdLoadAccessImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import java.util.HashSet;
88
import java.util.Set;
99

10+
import jakarta.persistence.EntityGraph;
11+
1012
import org.hibernate.HibernateException;
1113
import org.hibernate.IdentifierLoadAccess;
1214
import org.hibernate.LockOptions;
@@ -18,7 +20,6 @@
1820
import org.hibernate.engine.spi.SessionImplementor;
1921
import org.hibernate.engine.spi.Status;
2022
import org.hibernate.graph.GraphSemantic;
21-
import org.hibernate.graph.RootGraph;
2223
import org.hibernate.graph.spi.RootGraphImplementor;
2324
import org.hibernate.loader.LoaderLogging;
2425
import org.hibernate.loader.ast.spi.NaturalIdLoadOptions;
@@ -63,7 +64,7 @@ public LockOptions getLockOptions() {
6364
return lockOptions;
6465
}
6566

66-
public Object with(RootGraph<T> graph, GraphSemantic semantic) {
67+
public Object with(EntityGraph<T> graph, GraphSemantic semantic) {
6768
this.rootGraph = (RootGraphImplementor<T>) graph;
6869
this.graphSemantic = semantic;
6970
return this;

hibernate-core/src/main/java/org/hibernate/loader/internal/IdentifierLoadAccessImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import java.util.Set;
1010
import java.util.function.Supplier;
1111

12+
import jakarta.persistence.EntityGraph;
13+
1214
import org.hibernate.CacheMode;
1315
import org.hibernate.IdentifierLoadAccess;
1416
import org.hibernate.LockOptions;
@@ -23,7 +25,6 @@
2325
import org.hibernate.engine.spi.SessionImplementor;
2426
import org.hibernate.event.spi.LoadEventListener;
2527
import org.hibernate.graph.GraphSemantic;
26-
import org.hibernate.graph.RootGraph;
2728
import org.hibernate.graph.spi.RootGraphImplementor;
2829
import org.hibernate.metamodel.mapping.EntityMappingType;
2930
import org.hibernate.persister.entity.EntityPersister;
@@ -75,7 +76,7 @@ public IdentifierLoadAccess<T> withReadOnly(boolean readOnly) {
7576
}
7677

7778
@Override
78-
public IdentifierLoadAccess<T> with(RootGraph<T> graph, GraphSemantic semantic) {
79+
public IdentifierLoadAccess<T> with(EntityGraph<T> graph, GraphSemantic semantic) {
7980
this.rootGraph = (RootGraphImplementor<T>) graph;
8081
this.graphSemantic = semantic;
8182
return this;

hibernate-core/src/main/java/org/hibernate/loader/internal/NaturalIdLoadAccessImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
import java.util.Map;
99
import java.util.Optional;
1010

11+
import jakarta.persistence.EntityGraph;
1112
import jakarta.persistence.metamodel.SingularAttribute;
13+
1214
import org.hibernate.LockOptions;
1315
import org.hibernate.NaturalIdLoadAccess;
1416
import org.hibernate.graph.GraphSemantic;
15-
import org.hibernate.graph.RootGraph;
1617
import org.hibernate.metamodel.mapping.EntityMappingType;
1718

1819
/**
@@ -70,7 +71,7 @@ public Optional<T> loadOptional() {
7071
}
7172

7273
@Override
73-
public NaturalIdLoadAccess<T> with(RootGraph<T> graph, GraphSemantic semantic) {
74+
public NaturalIdLoadAccess<T> with(EntityGraph<T> graph, GraphSemantic semantic) {
7475
super.with( graph, semantic );
7576
return this;
7677
}

0 commit comments

Comments
 (0)