23
23
import org .hibernate .graph .spi .RootGraphImplementor ;
24
24
import org .hibernate .internal .FilterImpl ;
25
25
import org .hibernate .internal .SessionCreationOptions ;
26
- import org .hibernate .internal .util .NullnessUtil ;
27
26
import org .hibernate .loader .ast .spi .CascadingFetchProfile ;
28
27
import org .hibernate .persister .collection .CollectionPersister ;
29
28
import org .hibernate .persister .entity .EntityPersister ;
44
43
* @author Steve Ebersole
45
44
*/
46
45
public class LoadQueryInfluencers implements Serializable {
47
- /**
48
- * Static reference useful for cases where we are creating load SQL
49
- * outside the context of any influencers. One such example is
50
- * anything created by the session factory.
51
- *
52
- * @deprecated use {@link #LoadQueryInfluencers(SessionFactoryImplementor)}
53
- */
54
- @ Deprecated (forRemoval = true )
55
- public static final LoadQueryInfluencers NONE = new LoadQueryInfluencers ();
56
46
57
- private final @ Nullable SessionFactoryImplementor sessionFactory ;
47
+ private final SessionFactoryImplementor sessionFactory ;
58
48
59
49
private CascadingFetchProfile enabledCascadingFetchProfile ;
60
50
@@ -72,10 +62,6 @@ public class LoadQueryInfluencers implements Serializable {
72
62
73
63
private Boolean readOnly ;
74
64
75
- public LoadQueryInfluencers () {
76
- this .sessionFactory = null ;
77
- }
78
-
79
65
public LoadQueryInfluencers (SessionFactoryImplementor sessionFactory ) {
80
66
this .sessionFactory = sessionFactory ;
81
67
batchSize = sessionFactory .getSessionFactoryOptions ().getDefaultBatchFetchSize ();
@@ -99,7 +85,7 @@ public EffectiveEntityGraph applyEntityGraph(@Nullable RootGraphImplementor<?> r
99
85
return effectiveEntityGraph ;
100
86
}
101
87
102
- public @ Nullable SessionFactoryImplementor getSessionFactory () {
88
+ public SessionFactoryImplementor getSessionFactory () {
103
89
return sessionFactory ;
104
90
}
105
91
@@ -135,7 +121,6 @@ public boolean hasEnabledCascadingFetchProfile() {
135
121
* Set the effective {@linkplain #getEnabledCascadingFetchProfile() cascading fetch-profile}
136
122
*/
137
123
public void setEnabledCascadingFetchProfile (CascadingFetchProfile enabledCascadingFetchProfile ) {
138
- checkMutability ();
139
124
this .enabledCascadingFetchProfile = enabledCascadingFetchProfile ;
140
125
}
141
126
@@ -199,8 +184,7 @@ public Set<String> getEnabledFilterNames() {
199
184
}
200
185
201
186
public Filter enableFilter (String filterName ) {
202
- checkMutability ();
203
- FilterImpl filter = new FilterImpl ( NullnessUtil .castNonNull ( sessionFactory ).getFilterDefinition ( filterName ) );
187
+ FilterImpl filter = new FilterImpl ( sessionFactory .getFilterDefinition ( filterName ) );
204
188
if ( enabledFilters == null ) {
205
189
this .enabledFilters = new HashMap <>();
206
190
}
@@ -250,7 +234,7 @@ public Set<String> getEnabledFetchProfileNames() {
250
234
}
251
235
252
236
private void checkFetchProfileName (String name ) {
253
- if ( sessionFactory != null && !sessionFactory .containsFetchProfileDefinition ( name ) ) {
237
+ if ( !sessionFactory .containsFetchProfileDefinition ( name ) ) {
254
238
throw new UnknownProfileException ( name );
255
239
}
256
240
}
@@ -261,7 +245,6 @@ public boolean isFetchProfileEnabled(String name) throws UnknownProfileException
261
245
}
262
246
263
247
public void enableFetchProfile (String name ) throws UnknownProfileException {
264
- checkMutability ();
265
248
checkFetchProfileName ( name );
266
249
if ( enabledFetchProfileNames == null ) {
267
250
this .enabledFetchProfileNames = new HashSet <>();
@@ -368,14 +351,6 @@ private boolean isSubselectFetchEnabledInProfile(CollectionPersister persister)
368
351
return false ;
369
352
}
370
353
371
- private void checkMutability () {
372
- if ( sessionFactory == null ) {
373
- // that's the signal that this is the immutable, context-less
374
- // variety
375
- throw new IllegalStateException ( "Cannot modify context-less LoadQueryInfluencers" );
376
- }
377
- }
378
-
379
354
public boolean hasSubselectLoadableCollections (EntityPersister persister ) {
380
355
return persister .hasSubselectLoadableCollections ()
381
356
|| subselectFetchEnabled && persister .hasCollections ()
0 commit comments