Skip to content

Commit 7da9f64

Browse files
committed
HHH-19216 - NamedEntityGraph annotation supporting Hibernate parseable format
HHH-19237 - Expand graph language to optionally specify entity HHH-19217 - Expose GraphParser#parse on SessionFactory
1 parent 3e61743 commit 7da9f64

File tree

5 files changed

+7
-23
lines changed

5 files changed

+7
-23
lines changed

hibernate-core/src/main/java/org/hibernate/boot/model/NamedGraphCreator.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import org.hibernate.graph.spi.RootGraphImplementor;
88
import org.hibernate.metamodel.model.domain.EntityDomainType;
9-
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
109

1110
import java.util.function.Function;
1211

@@ -17,6 +16,5 @@
1716
public interface NamedGraphCreator {
1817
<T> RootGraphImplementor<T> createEntityGraph(
1918
Function<Class<T>, EntityDomainType<?>> entityDomainClassResolver,
20-
Function<String, EntityDomainType<?>> entityDomainNameResolver,
21-
RuntimeModelCreationContext runtimeModelCreationContext);
19+
Function<String, EntityDomainType<?>> entityDomainNameResolver);
2220
}

hibernate-core/src/main/java/org/hibernate/boot/model/NamedGraphCreatorJpa.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.hibernate.graph.spi.SubGraphImplementor;
1717
import org.hibernate.internal.util.NullnessHelper;
1818
import org.hibernate.metamodel.model.domain.EntityDomainType;
19-
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
2019

2120
import java.util.function.Function;
2221

@@ -39,8 +38,7 @@ public NamedGraphCreatorJpa(NamedEntityGraph annotation, String jpaEntityName) {
3938
@Override
4039
public <T> RootGraphImplementor<T> createEntityGraph(
4140
Function<Class<T>, EntityDomainType<?>> entityDomainClassResolver,
42-
Function<String, EntityDomainType<?>> entityDomainNameResolver,
43-
RuntimeModelCreationContext runtimeModelCreationContext) {
41+
Function<String, EntityDomainType<?>> entityDomainNameResolver) {
4442
//noinspection unchecked
4543
final EntityDomainType<T> rootEntityType = (EntityDomainType<T>) entityDomainNameResolver.apply( jpaEntityName );
4644
final RootGraphImplementor<T> entityGraph = createRootGraph( name, rootEntityType, annotation.includeAllAttributes() );

hibernate-core/src/main/java/org/hibernate/boot/model/NamedGraphCreatorParsed.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import org.hibernate.graph.internal.parse.GraphParsing;
1616
import org.hibernate.graph.spi.RootGraphImplementor;
1717
import org.hibernate.metamodel.model.domain.EntityDomainType;
18-
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
1918

2019
import java.util.function.Function;
2120

@@ -38,8 +37,7 @@ public NamedGraphCreatorParsed(Class<?> entityType, NamedEntityGraph annotation)
3837
@Override
3938
public <T> RootGraphImplementor<T> createEntityGraph(
4039
Function<Class<T>, EntityDomainType<?>> entityDomainClassResolver,
41-
Function<String, EntityDomainType<?>> entityDomainNameResolver,
42-
RuntimeModelCreationContext runtimeModelCreationContext) {
40+
Function<String, EntityDomainType<?>> entityDomainNameResolver) {
4341
final GraphLanguageLexer lexer = new GraphLanguageLexer( CharStreams.fromString( annotation.graph() ) );
4442
final GraphLanguageParser parser = new GraphLanguageParser( new CommonTokenStream( lexer ) );
4543
final GraphLanguageParser.GraphContext graphContext = parser.graph();

hibernate-core/src/main/java/org/hibernate/graph/internal/parse/GraphParsing.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,13 @@ public static <T> RootGraphImplementor<T> parse(
138138

139139
/**
140140
* Parse the passed graph textual representation into the passed Graph.
141+
* Essentially overlays the text representation on top of the graph.
141142
*/
142143
public static void parseInto(
143144
GraphImplementor<?> targetGraph,
144-
String graphString,
145+
CharSequence graphString,
145146
SessionFactoryImplementor sessionFactory) {
146-
final GraphLanguageLexer lexer = new GraphLanguageLexer( CharStreams.fromString( graphString ) );
147+
final GraphLanguageLexer lexer = new GraphLanguageLexer( CharStreams.fromString( graphString.toString() ) );
147148
final GraphLanguageParser parser = new GraphLanguageParser( new CommonTokenStream( lexer ) );
148149
final GraphLanguageParser.GraphContext graphContext = parser.graph();
149150

@@ -165,14 +166,4 @@ public static void parseInto(
165166
assert visitor.getGraphStack().isEmpty();
166167
}
167168
}
168-
169-
/**
170-
* Parse the passed graph textual representation into the passed Graph.
171-
*/
172-
public static void parseInto(
173-
GraphImplementor<?> targetGraph,
174-
CharSequence graphString,
175-
SessionFactoryImplementor sessionFactory) {
176-
parseInto( targetGraph, graphString.toString(), sessionFactory );
177-
}
178169
}

hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/JpaMetamodelImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,7 @@ private void applyNamedEntityGraphs(Collection<NamedEntityGraphDefinition> named
516516
}
517517
}
518518
throw new IllegalArgumentException( "Cannot resolve entity name : " + jpaEntityName );
519-
},
520-
runtimeModelCreationContext
519+
}
521520
);
522521
entityGraphMap.put( definition.getRegisteredName(), graph );
523522
}

0 commit comments

Comments
 (0)