Skip to content

Commit fa56009

Browse files
committed
pull implementations down off SessionFactory
1 parent 51c9d54 commit fa56009

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

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

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import jakarta.persistence.TypedQueryReference;
1414
import org.hibernate.boot.spi.SessionFactoryOptions;
1515
import org.hibernate.engine.spi.FilterDefinition;
16-
import org.hibernate.engine.spi.SessionFactoryImplementor;
1716
import org.hibernate.graph.GraphParser;
1817
import org.hibernate.graph.InvalidGraphException;
1918
import org.hibernate.graph.RootGraph;
@@ -108,7 +107,7 @@
108107
* SingularAttribute<Book,String>}.
109108
* </ul>
110109
* <p>
111-
* Use of these statically-typed metamodel references is the preferred way of
110+
* Use of these statically typed metamodel references is the preferred way of
112111
* working with the {@linkplain jakarta.persistence.criteria.CriteriaBuilder
113112
* criteria query API}, and with {@linkplain EntityGraph}s.
114113
* <p>
@@ -266,7 +265,7 @@ default void inSession(Consumer<? super Session> action) {
266265
* @since 6.3
267266
*/
268267
default void inStatelessSession(Consumer<? super StatelessSession> action) {
269-
try ( StatelessSession session = openStatelessSession() ) {
268+
try ( var session = openStatelessSession() ) {
270269
action.accept( session );
271270
}
272271
}
@@ -308,7 +307,7 @@ default void inStatelessTransaction(Consumer<? super StatelessSession> action) {
308307
* @see #fromTransaction(Function)
309308
*/
310309
default <R> R fromSession(Function<? super Session,R> action) {
311-
try ( Session session = openSession() ) {
310+
try ( var session = openSession() ) {
312311
return action.apply( session );
313312
}
314313
}
@@ -331,7 +330,7 @@ default <R> R fromSession(Function<? super Session,R> action) {
331330
* @since 6.3
332331
*/
333332
default <R> R fromStatelessSession(Function<? super StatelessSession,R> action) {
334-
try ( StatelessSession session = openStatelessSession() ) {
333+
try ( var session = openStatelessSession() ) {
335334
return action.apply( session );
336335
}
337336
}
@@ -522,9 +521,7 @@ default <T> RootGraph<T> createEntityGraph(Class<T> entityType) {
522521
*
523522
* @since 7.0
524523
*/
525-
default <T> RootGraph<T> parseEntityGraph(Class<T> rootEntityClass, CharSequence graphText) {
526-
return GraphParser.parse( rootEntityClass, graphText.toString(), unwrap( SessionFactoryImplementor.class ) );
527-
}
524+
<T> RootGraph<T> parseEntityGraph(Class<T> rootEntityClass, CharSequence graphText);
528525

529526
/**
530527
* Creates a {@link RootGraph} for the given {@code rootEntityName} and parses the graph
@@ -544,9 +541,7 @@ default <T> RootGraph<T> parseEntityGraph(Class<T> rootEntityClass, CharSequence
544541
* @since 7.0
545542
*/
546543
@Incubating
547-
default <T> RootGraph<T> parseEntityGraph(String rootEntityName, CharSequence graphText) {
548-
return GraphParser.parse( rootEntityName, graphText.toString(), unwrap( SessionFactoryImplementor.class ) );
549-
}
544+
<T> RootGraph<T> parseEntityGraph(String rootEntityName, CharSequence graphText);
550545

551546
/**
552547
* Creates a {@link RootGraph} based on the passed string representation. Here, the
@@ -562,9 +557,7 @@ default <T> RootGraph<T> parseEntityGraph(String rootEntityName, CharSequence gr
562557
* @since 7.0
563558
*/
564559
@Incubating
565-
default <T> RootGraph<T> parseEntityGraph(CharSequence graphText) {
566-
return GraphParser.parse( graphText.toString(), unwrap( SessionFactoryImplementor.class ) );
567-
}
560+
<T> RootGraph<T> parseEntityGraph(CharSequence graphText);
568561

569562
/**
570563
* Obtain the set of names of all {@linkplain org.hibernate.annotations.FilterDef

hibernate-core/src/main/java/org/hibernate/engine/spi/SessionFactoryImplementor.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import org.hibernate.event.service.spi.EventListenerRegistry;
2424
import org.hibernate.event.spi.EntityCopyObserverFactory;
2525
import org.hibernate.event.spi.EventEngine;
26+
import org.hibernate.graph.GraphParser;
27+
import org.hibernate.graph.RootGraph;
2628
import org.hibernate.graph.spi.RootGraphImplementor;
2729
import org.hibernate.event.service.spi.EventListenerGroups;
2830
import org.hibernate.metamodel.model.domain.JpaMetamodel;
@@ -322,4 +324,18 @@ default JdbcSelectWithActionsBuilder getJdbcSelectWithActionsBuilder(){
322324
return new JdbcSelectWithActions.Builder();
323325
}
324326

327+
@Override
328+
default <T> RootGraph<T> parseEntityGraph(Class<T> rootEntityClass, CharSequence graphText) {
329+
return GraphParser.parse( rootEntityClass, graphText.toString(), unwrap( SessionFactoryImplementor.class ) );
330+
}
331+
332+
@Override @Incubating
333+
default <T> RootGraph<T> parseEntityGraph(String rootEntityName, CharSequence graphText) {
334+
return GraphParser.parse( rootEntityName, graphText.toString(), unwrap( SessionFactoryImplementor.class ) );
335+
}
336+
337+
@Override @Incubating
338+
default <T> RootGraph<T> parseEntityGraph(CharSequence graphText) {
339+
return GraphParser.parse( graphText.toString(), unwrap( SessionFactoryImplementor.class ) );
340+
}
325341
}

0 commit comments

Comments
 (0)