diff --git a/hibernate-core/src/main/java/org/hibernate/SessionFactory.java b/hibernate-core/src/main/java/org/hibernate/SessionFactory.java
index c03e63bd2ad7..184e9da8b18f 100644
--- a/hibernate-core/src/main/java/org/hibernate/SessionFactory.java
+++ b/hibernate-core/src/main/java/org/hibernate/SessionFactory.java
@@ -13,7 +13,6 @@
import jakarta.persistence.TypedQueryReference;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.engine.spi.FilterDefinition;
-import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.graph.GraphParser;
import org.hibernate.graph.InvalidGraphException;
import org.hibernate.graph.RootGraph;
@@ -108,7 +107,7 @@
* SingularAttribute<Book,String>}.
*
*
- * Use of these statically-typed metamodel references is the preferred way of
+ * Use of these statically typed metamodel references is the preferred way of
* working with the {@linkplain jakarta.persistence.criteria.CriteriaBuilder
* criteria query API}, and with {@linkplain EntityGraph}s.
*
@@ -266,7 +265,7 @@ default void inSession(Consumer super Session> action) {
* @since 6.3
*/
default void inStatelessSession(Consumer super StatelessSession> action) {
- try ( StatelessSession session = openStatelessSession() ) {
+ try ( var session = openStatelessSession() ) {
action.accept( session );
}
}
@@ -308,7 +307,7 @@ default void inStatelessTransaction(Consumer super StatelessSession> action) {
* @see #fromTransaction(Function)
*/
default R fromSession(Function super Session,R> action) {
- try ( Session session = openSession() ) {
+ try ( var session = openSession() ) {
return action.apply( session );
}
}
@@ -331,7 +330,7 @@ default R fromSession(Function super Session,R> action) {
* @since 6.3
*/
default R fromStatelessSession(Function super StatelessSession,R> action) {
- try ( StatelessSession session = openStatelessSession() ) {
+ try ( var session = openStatelessSession() ) {
return action.apply( session );
}
}
@@ -522,9 +521,7 @@ default RootGraph createEntityGraph(Class entityType) {
*
* @since 7.0
*/
- default RootGraph parseEntityGraph(Class rootEntityClass, CharSequence graphText) {
- return GraphParser.parse( rootEntityClass, graphText.toString(), unwrap( SessionFactoryImplementor.class ) );
- }
+ RootGraph parseEntityGraph(Class rootEntityClass, CharSequence graphText);
/**
* Creates a {@link RootGraph} for the given {@code rootEntityName} and parses the graph
@@ -543,9 +540,8 @@ default RootGraph parseEntityGraph(Class rootEntityClass, CharSequence
*
* @since 7.0
*/
- default RootGraph parseEntityGraph(String rootEntityName, CharSequence graphText) {
- return GraphParser.parse( rootEntityName, graphText.toString(), unwrap( SessionFactoryImplementor.class ) );
- }
+ @Incubating
+ RootGraph parseEntityGraph(String rootEntityName, CharSequence graphText);
/**
* Creates a {@link RootGraph} based on the passed string representation. Here, the
@@ -560,9 +556,8 @@ default RootGraph parseEntityGraph(String rootEntityName, CharSequence gr
*
* @since 7.0
*/
- default RootGraph parseEntityGraph(CharSequence graphText) {
- return GraphParser.parse( graphText.toString(), unwrap( SessionFactoryImplementor.class ) );
- }
+ @Incubating
+ RootGraph parseEntityGraph(CharSequence graphText);
/**
* Obtain the set of names of all {@linkplain org.hibernate.annotations.FilterDef
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/NamedGraphCreator.java b/hibernate-core/src/main/java/org/hibernate/boot/model/NamedGraphCreator.java
index 026af3d8f896..098fbbe844e2 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/model/NamedGraphCreator.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/NamedGraphCreator.java
@@ -4,17 +4,16 @@
*/
package org.hibernate.boot.model;
+import org.hibernate.graph.spi.GraphParserEntityClassResolver;
+import org.hibernate.graph.spi.GraphParserEntityNameResolver;
import org.hibernate.graph.spi.RootGraphImplementor;
-import org.hibernate.metamodel.model.domain.EntityDomainType;
-
-import java.util.function.Function;
/**
* @author Steve Ebersole
*/
@FunctionalInterface
public interface NamedGraphCreator {
- RootGraphImplementor createEntityGraph(
- Function, EntityDomainType>> entityDomainClassResolver,
- Function> entityDomainNameResolver);
+ RootGraphImplementor> createEntityGraph(
+ GraphParserEntityClassResolver entityDomainClassResolver,
+ GraphParserEntityNameResolver entityDomainNameResolver);
}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/NamedGraphCreatorJpa.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/NamedGraphCreatorJpa.java
index 9aebd53de1c2..852df030cc65 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/NamedGraphCreatorJpa.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/NamedGraphCreatorJpa.java
@@ -6,17 +6,18 @@
import jakarta.persistence.NamedAttributeNode;
import jakarta.persistence.NamedEntityGraph;
+import org.checkerframework.checker.nullness.qual.NonNull;
import org.hibernate.AnnotationException;
import org.hibernate.boot.model.NamedGraphCreator;
import org.hibernate.graph.internal.RootGraphImpl;
import org.hibernate.graph.spi.AttributeNodeImplementor;
+import org.hibernate.graph.spi.GraphParserEntityClassResolver;
+import org.hibernate.graph.spi.GraphParserEntityNameResolver;
import org.hibernate.graph.spi.GraphImplementor;
import org.hibernate.graph.spi.RootGraphImplementor;
import org.hibernate.graph.spi.SubGraphImplementor;
import org.hibernate.metamodel.model.domain.EntityDomainType;
-import java.util.function.Function;
-
import static org.hibernate.internal.util.StringHelper.isNotEmpty;
import static org.hibernate.internal.util.StringHelper.nullIfEmpty;
@@ -36,16 +37,16 @@ class NamedGraphCreatorJpa implements NamedGraphCreator {
}
@Override
- public RootGraphImplementor createEntityGraph(
- Function, EntityDomainType>> entityDomainClassResolver,
- Function> entityDomainNameResolver) {
- //noinspection unchecked
- final var rootEntityType =
- (EntityDomainType)
- entityDomainNameResolver.apply( jpaEntityName );
+ public RootGraphImplementor> createEntityGraph(
+ GraphParserEntityClassResolver entityDomainClassResolver,
+ GraphParserEntityNameResolver entityDomainNameResolver) {
+ return createGraph( (EntityDomainType>)
+ entityDomainNameResolver.resolveEntityName( jpaEntityName ) );
+ }
+
+ private @NonNull RootGraphImplementor createGraph(EntityDomainType rootEntityType) {
final var entityGraph =
createRootGraph( name, rootEntityType, annotation.includeAllAttributes() );
-
final var subclassSubgraphs = annotation.subclassSubgraphs();
if ( subclassSubgraphs != null ) {
for ( var subclassSubgraph : subclassSubgraphs ) {
@@ -59,11 +60,9 @@ public RootGraphImplementor createEntityGraph(
entityGraph.addTreatedSubgraph( subgraphType.asSubclass( graphJavaType ) ) );
}
}
-
if ( annotation.attributeNodes() != null ) {
applyNamedAttributeNodes( annotation.attributeNodes(), annotation, entityGraph );
}
-
return entityGraph;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/NamedGraphCreatorParsed.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/NamedGraphCreatorParsed.java
index a264f3521fd2..ed0ca3054e50 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/NamedGraphCreatorParsed.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/NamedGraphCreatorParsed.java
@@ -6,6 +6,7 @@
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream;
+import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.hibernate.UnknownEntityTypeException;
import org.hibernate.annotations.NamedEntityGraph;
@@ -13,13 +14,12 @@
import org.hibernate.grammars.graph.GraphLanguageLexer;
import org.hibernate.grammars.graph.GraphLanguageParser;
import org.hibernate.graph.InvalidGraphException;
-import org.hibernate.graph.internal.parse.EntityNameResolver;
+import org.hibernate.graph.spi.GraphParserEntityClassResolver;
+import org.hibernate.graph.spi.GraphParserEntityNameResolver;
import org.hibernate.graph.internal.parse.GraphParsing;
import org.hibernate.graph.spi.RootGraphImplementor;
import org.hibernate.metamodel.model.domain.EntityDomainType;
-import java.util.function.Function;
-
import static org.hibernate.internal.util.StringHelper.nullIfEmpty;
/**
@@ -41,43 +41,52 @@ class NamedGraphCreatorParsed implements NamedGraphCreator {
}
@Override
- public RootGraphImplementor createEntityGraph(
- Function, EntityDomainType>> entityDomainClassResolver,
- Function> entityDomainNameResolver) {
- final GraphLanguageLexer lexer = new GraphLanguageLexer( CharStreams.fromString( annotation.graph() ) );
- final GraphLanguageParser parser = new GraphLanguageParser( new CommonTokenStream( lexer ) );
- final GraphLanguageParser.GraphContext graphContext = parser.graph();
-
- final EntityNameResolver entityNameResolver = new EntityNameResolver() {
- @Override
- public EntityDomainType resolveEntityName(String entityName) {
- //noinspection unchecked
- final EntityDomainType entityDomainType = (EntityDomainType) entityDomainNameResolver.apply( entityName );
- if ( entityDomainType != null ) {
- return entityDomainType;
- }
- throw new UnknownEntityTypeException( entityName );
- }
- };
+ public RootGraphImplementor> createEntityGraph(
+ GraphParserEntityClassResolver entityDomainClassResolver,
+ GraphParserEntityNameResolver entityDomainNameResolver) {
+ final var lexer = new GraphLanguageLexer( CharStreams.fromString( annotation.graph() ) );
+ final var parser = new GraphLanguageParser( new CommonTokenStream( lexer ) );
+ final var graphContext = parser.graph();
+ final var typeIndicator = graphContext.typeIndicator();
if ( entityType == null ) {
- if ( graphContext.typeIndicator() == null ) {
+ if ( typeIndicator == null ) {
throw new InvalidGraphException( "Expecting graph text to include an entity name : " + annotation.graph() );
}
- final String jpaEntityName = graphContext.typeIndicator().TYPE_NAME().toString();
- //noinspection unchecked
- final EntityDomainType entityDomainType = (EntityDomainType) entityDomainNameResolver.apply( jpaEntityName );
+ final String jpaEntityName = typeIndicator.TYPE_NAME().toString();
+ final var entityDomainType = entityDomainNameResolver.resolveEntityName( jpaEntityName );
final String name = this.name == null ? jpaEntityName : this.name;
- return GraphParsing.parse( name, entityDomainType, graphContext.attributeList(), entityNameResolver );
+ return parse( entityDomainNameResolver, name, entityDomainType, graphContext );
}
else {
- if ( graphContext.typeIndicator() != null ) {
+ if ( typeIndicator != null ) {
throw new InvalidGraphException( "Expecting graph text to not include an entity name : " + annotation.graph() );
}
- //noinspection unchecked
- final EntityDomainType entityDomainType = (EntityDomainType) entityDomainClassResolver.apply( (Class) entityType );
+ final var entityDomainType = entityDomainClassResolver.resolveEntityClass( entityType );
final String name = this.name == null ? entityDomainType.getName() : this.name;
- return GraphParsing.parse( name, entityDomainType, graphContext.attributeList(), entityNameResolver );
+ return parse( entityDomainNameResolver, name, entityDomainType, graphContext );
+ }
+ }
+
+ private static @NonNull RootGraphImplementor> parse(
+ GraphParserEntityNameResolver entityDomainNameResolver,
+ String name,
+ EntityDomainType> entityDomainType,
+ GraphLanguageParser.GraphContext graphContext) {
+ return GraphParsing.parse( name, entityDomainType, graphContext.attributeList(),
+ entityName -> resolve( entityName, entityDomainNameResolver ) );
+ }
+
+ private static @NonNull EntityDomainType> resolve(
+ String entityName, GraphParserEntityNameResolver entityDomainNameResolver) {
+ final var entityDomainType =
+ (EntityDomainType>)
+ entityDomainNameResolver.resolveEntityName( entityName );
+ if ( entityDomainType == null ) {
+ throw new UnknownEntityTypeException( entityName );
+ }
+ else {
+ return entityDomainType;
}
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/NaturalIdBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/NaturalIdBinder.java
index 626c1d6d4081..98d5f8a5d6ab 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/NaturalIdBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/NaturalIdBinder.java
@@ -53,7 +53,7 @@ private static Identifier uniqueKeyName(MetadataBuildingContext context, Annotat
private static void addColumnsToUniqueKey(AnnotatedColumns columns, Identifier name) {
final var collector = columns.getBuildingContext().getMetadataCollector();
- final Table table = columns.getTable();
+ final var table = columns.getTable();
final var uniqueKey = table.getOrCreateUniqueKey( name.render( collector.getDatabase().getDialect() ) );
final var property = columns.resolveProperty();
if ( property.isComposite() ) {
diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionFactoryImplementor.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionFactoryImplementor.java
index 84831c176e26..a83bf40786a6 100644
--- a/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionFactoryImplementor.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionFactoryImplementor.java
@@ -23,6 +23,8 @@
import org.hibernate.event.service.spi.EventListenerRegistry;
import org.hibernate.event.spi.EntityCopyObserverFactory;
import org.hibernate.event.spi.EventEngine;
+import org.hibernate.graph.GraphParser;
+import org.hibernate.graph.RootGraph;
import org.hibernate.graph.spi.RootGraphImplementor;
import org.hibernate.event.service.spi.EventListenerGroups;
import org.hibernate.metamodel.model.domain.JpaMetamodel;
@@ -322,4 +324,18 @@ default JdbcSelectWithActionsBuilder getJdbcSelectWithActionsBuilder(){
return new JdbcSelectWithActions.Builder();
}
+ @Override
+ default RootGraph parseEntityGraph(Class rootEntityClass, CharSequence graphText) {
+ return GraphParser.parse( rootEntityClass, graphText.toString(), unwrap( SessionFactoryImplementor.class ) );
+ }
+
+ @Override @Incubating
+ default RootGraph parseEntityGraph(String rootEntityName, CharSequence graphText) {
+ return GraphParser.parse( rootEntityName, graphText.toString(), unwrap( SessionFactoryImplementor.class ) );
+ }
+
+ @Override @Incubating
+ default RootGraph parseEntityGraph(CharSequence graphText) {
+ return GraphParser.parse( graphText.toString(), unwrap( SessionFactoryImplementor.class ) );
+ }
}
diff --git a/hibernate-core/src/main/java/org/hibernate/graph/GraphParser.java b/hibernate-core/src/main/java/org/hibernate/graph/GraphParser.java
index 0bfcb46624ad..ae5ca1086929 100644
--- a/hibernate-core/src/main/java/org/hibernate/graph/GraphParser.java
+++ b/hibernate-core/src/main/java/org/hibernate/graph/GraphParser.java
@@ -9,6 +9,7 @@
import jakarta.persistence.EntityManagerFactory;
import jakarta.persistence.Subgraph;
+import org.hibernate.Incubating;
import org.hibernate.SessionFactory;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SessionImplementor;
@@ -89,6 +90,7 @@ public static RootGraph parse(
*
* @since 7.0
*/
+ @Incubating
public static RootGraph parse(
final String rootEntityName,
final CharSequence graphText,
@@ -96,7 +98,8 @@ public static RootGraph parse(
if ( graphText == null ) {
return null;
}
- return GraphParsing.parse(
+ //noinspection unchecked
+ return (RootGraph) GraphParsing.parse(
rootEntityName,
graphText.toString(),
sessionFactory.unwrap( SessionFactoryImplementor.class )
@@ -117,16 +120,18 @@ public static RootGraph parse(
*
* @since 7.0
*/
- public static RootGraph parse(
+ @Incubating
+ public static RootGraph parse(
final CharSequence graphText,
final SessionFactory sessionFactory) {
if ( graphText == null ) {
return null;
}
- return GraphParsing.parse(
+ //noinspection unchecked
+ return (RootGraph) GraphParsing.parse(
graphText.toString(),
sessionFactory.unwrap( SessionFactoryImplementor.class )
- );
+ );
}
/**
@@ -153,7 +158,8 @@ public static RootGraph parse(
return GraphParsing.parse(
rootType,
graphText.toString(),
- entityManager.getEntityManagerFactory().unwrap( SessionFactoryImplementor.class )
+ entityManager.getEntityManagerFactory()
+ .unwrap( SessionFactoryImplementor.class )
);
}
@@ -190,13 +196,12 @@ public static void parseInto(
*
* @throws InvalidGraphException if the textual representation is invalid.
*/
- @SuppressWarnings("unchecked")
public static void parseInto(
- final EntityGraph graph,
+ final EntityGraph> graph,
final CharSequence graphText,
final EntityManager entityManager) {
parseInto(
- (GraphImplementor) graph,
+ (GraphImplementor>) graph,
graphText,
( (SessionImplementor) entityManager ).getSessionFactory()
);
@@ -211,13 +216,12 @@ public static void parseInto(
*
* @throws InvalidGraphException if the textual representation is invalid.
*/
- @SuppressWarnings("unchecked")
- public static void parseInto(
- final Subgraph graph,
+ public static void parseInto(
+ final Subgraph> graph,
final CharSequence graphText,
final EntityManager entityManager) {
parseInto(
- (GraphImplementor) graph,
+ (GraphImplementor>) graph,
graphText,
( (SessionImplementor) entityManager ).getSessionFactory()
);
@@ -232,12 +236,12 @@ public static void parseInto(
*
* @throws InvalidGraphException if the textual representation is invalid.
*/
- public static void parseInto(
- final Graph graph,
+ public static void parseInto(
+ final Graph> graph,
final CharSequence graphText,
final EntityManagerFactory entityManagerFactory) {
parseInto(
- (GraphImplementor) graph,
+ (GraphImplementor>) graph,
graphText,
(SessionFactoryImplementor) entityManagerFactory
);
@@ -252,13 +256,12 @@ public static void parseInto(
*
* @throws InvalidGraphException if the textual representation is invalid.
*/
- @SuppressWarnings("unchecked")
- public static void parseInto(
- final EntityGraph graph,
+ public static void parseInto(
+ final EntityGraph> graph,
final CharSequence graphText,
final EntityManagerFactory entityManagerFactory) {
parseInto(
- (GraphImplementor) graph,
+ (GraphImplementor>) graph,
graphText,
(SessionFactoryImplementor) entityManagerFactory
);
@@ -273,13 +276,12 @@ public static void parseInto(
*
* @throws InvalidGraphException if the textual representation is invalid.
*/
- @SuppressWarnings("unchecked")
- public static void parseInto(
- final Subgraph graph,
+ public static void parseInto(
+ final Subgraph> graph,
final CharSequence graphText,
final EntityManagerFactory entityManagerFactory) {
parseInto(
- (GraphImplementor) graph,
+ (GraphImplementor>) graph,
graphText,
(SessionFactoryImplementor) entityManagerFactory
);
@@ -289,8 +291,6 @@ public static void parseInto(
* Parses the textual graph representation as {@linkplain GraphParser described above}
* into the specified graph.
*
- * @param The Java type for the ManagedType described by `graph`
- *
* @param graph The target graph. This is the graph that will be populated
* by this process
* @param graphText Textual representation of the graph
@@ -298,8 +298,8 @@ public static void parseInto(
*
* @throws InvalidGraphException if the textual representation is invalid.
*/
- private static void parseInto(
- GraphImplementor graph,
+ private static void parseInto(
+ GraphImplementor> graph,
final CharSequence graphText,
SessionFactoryImplementor sessionFactory) {
if ( graphText != null ) {
diff --git a/hibernate-core/src/main/java/org/hibernate/graph/internal/AttributeNodeImpl.java b/hibernate-core/src/main/java/org/hibernate/graph/internal/AttributeNodeImpl.java
index 6856698ea440..dd25ee52bc47 100644
--- a/hibernate-core/src/main/java/org/hibernate/graph/internal/AttributeNodeImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/graph/internal/AttributeNodeImpl.java
@@ -258,13 +258,13 @@ public SubGraphImplementor makeSubGraph() {
@Override @Deprecated
public SubGraphImplementor makeSubGraph(Class subtype) {
- final ManagedDomainType managedType = asManagedType( valueGraphType );
+ final var managedType = asManagedType( valueGraphType );
if ( !managedType.getJavaType().isAssignableFrom( subtype ) ) {
throw new IllegalArgumentException( "Not a subtype: " + subtype.getName() );
}
@SuppressWarnings("unchecked")
- final Class extends E> castSuptype = (Class extends E>) subtype;
- final SubGraphImplementor extends E> result = makeSubGraph().addTreatedSubgraph( castSuptype );
+ final var castSuptype = (Class extends E>) subtype;
+ final var result = makeSubGraph().addTreatedSubgraph( castSuptype );
//noinspection unchecked
return (SubGraphImplementor) result;
}
@@ -282,13 +282,13 @@ public SubGraphImplementor makeKeySubGraph() {
@Override @Deprecated
public SubGraphImplementor makeKeySubGraph(Class subtype) {
checkMap();
- final ManagedDomainType type = asManagedType( keyGraphType );
+ final var type = asManagedType( keyGraphType );
if ( !type.getJavaType().isAssignableFrom( subtype ) ) {
throw new IllegalArgumentException( "Not a key subtype: " + subtype.getName() );
}
@SuppressWarnings("unchecked")
- final Class extends K> castType = (Class extends K>) subtype;
- final SubGraphImplementor extends K> result = makeKeySubGraph().addTreatedSubgraph( castType );
+ final var castType = (Class extends K>) subtype;
+ final var result = makeKeySubGraph().addTreatedSubgraph( castType );
//noinspection unchecked
return (SubGraphImplementor) result;
}
@@ -323,7 +323,7 @@ public String toString() {
public void merge(AttributeNodeImplementor that) {
assert that.isMutable() == isMutable();
assert that.getAttributeDescriptor() == attribute;
- final SubGraphImplementor otherValueSubgraph = that.getValueSubgraph();
+ final var otherValueSubgraph = that.getValueSubgraph();
if ( otherValueSubgraph != null ) {
if ( valueSubgraph == null ) {
valueSubgraph = otherValueSubgraph.makeCopy( isMutable() );
@@ -333,7 +333,7 @@ public void merge(AttributeNodeImplementor that) {
valueSubgraph.mergeInternal( otherValueSubgraph );
}
}
- final SubGraphImplementor otherKeySubgraph = that.getKeySubgraph();
+ final var otherKeySubgraph = that.getKeySubgraph();
if ( otherKeySubgraph != null ) {
if ( keySubgraph == null ) {
keySubgraph = otherKeySubgraph.makeCopy( isMutable() );
@@ -351,7 +351,8 @@ public Map, SubGraphImplementor>> getSubGraphs() {
return emptyMap();
}
else {
- final HashMap, SubGraphImplementor>> map = new HashMap<>( valueSubgraph.getTreatedSubgraphs() );
+ final HashMap, SubGraphImplementor>> map =
+ new HashMap<>( valueSubgraph.getTreatedSubgraphs() );
map.put( attribute.getValueGraphType().getJavaType(), valueSubgraph );
return map;
}
@@ -363,7 +364,8 @@ public Map, SubGraphImplementor>> getKeySubGraphs() {
return emptyMap();
}
else {
- final HashMap, SubGraphImplementor>> map = new HashMap<>( keySubgraph.getTreatedSubgraphs() );
+ final HashMap, SubGraphImplementor>> map =
+ new HashMap<>( keySubgraph.getTreatedSubgraphs() );
map.put( attribute.getKeyGraphType().getJavaType(), keySubgraph );
return map;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/graph/internal/GraphImpl.java b/hibernate-core/src/main/java/org/hibernate/graph/internal/GraphImpl.java
index b28471f203f8..0a78778d88e9 100644
--- a/hibernate-core/src/main/java/org/hibernate/graph/internal/GraphImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/graph/internal/GraphImpl.java
@@ -156,19 +156,19 @@ public void mergeInternal(GraphImplementor graph) {
}
private void mergeNode(PersistentAttribute super J, ?> attribute, AttributeNodeImplementor,?,?> node) {
- final AttributeNodeImplementor,?,?> existingNode = getNodeForPut( attribute );
+ final var existingNode = getNodeForPut( attribute );
if ( existingNode == null ) {
attributeNodes.put( attribute, node.makeCopy( isMutable() ) );
}
else {
- // keep the local one, but merge in the incoming one
+ // keep the local one but merge in the incoming one
mergeNode( node, existingNode );
}
}
private void mergeGraph(SubGraphImplementor subgraph) {
- final Class javaType = subgraph.getClassType();
- final SubGraphImplementor existing = getTreatedSubgraphForPut( javaType );
+ final var javaType = subgraph.getClassType();
+ final var existing = getTreatedSubgraphForPut( javaType );
if ( existing == null ) {
treatedSubgraphs.put( javaType, subgraph.makeCopy( isMutable() ) );
}
@@ -197,12 +197,12 @@ public List> getAttributeNodeList() {
@Override
public AttributeNodeImplementor findAttributeNode(String attributeName) {
- final PersistentAttribute super J, ?> attribute = findAttributeInSupertypes( attributeName );
+ final var attribute = findAttributeInSupertypes( attributeName );
@SuppressWarnings("unchecked") // The JPA API is unsafe by nature
- final PersistentAttribute super J, AJ> persistentAttribute = (PersistentAttribute super J, AJ>) attribute;
- final AttributeNodeImplementor node = attribute == null ? null : findAttributeNode( persistentAttribute );
+ final var persistentAttribute = (PersistentAttribute super J, AJ>) attribute;
+ final var node = attribute == null ? null : findAttributeNode( persistentAttribute );
if ( node == null && treatedSubgraphs != null ) {
- for ( SubGraphImplementor> subgraph : treatedSubgraphs.values() ) {
+ for ( var subgraph : treatedSubgraphs.values() ) {
final AttributeNodeImplementor subgraphNode = subgraph.findAttributeNode( attributeName );
if ( subgraphNode != null ) {
return subgraphNode;
@@ -264,7 +264,7 @@ public void addAttributeNodes(String... attributeNames) {
@Override @SafeVarargs
public final void addAttributeNodes(Attribute super J, ?>... attributes) {
- for ( Attribute super J, ?> attribute : attributes ) {
+ for ( var attribute : attributes ) {
addAttributeNode( attribute );
}
}
@@ -290,9 +290,9 @@ public void removeAttributeNodes(Attribute.PersistentAttributeType nodeType) {
@Override
public AttributeNodeImplementor findOrCreateAttributeNode(PersistentAttribute super J, AJ> attribute) {
verifyMutability();
- final AttributeNodeImplementor node = getNodeForPut( attribute );
+ final var node = getNodeForPut( attribute );
if ( node == null ) {
- final AttributeNodeImplementor newAttrNode = AttributeNodeImpl.create( attribute, isMutable() );
+ final var newAttrNode = AttributeNodeImpl.create( attribute, isMutable() );
attributeNodes.put( attribute, newAttrNode );
return newAttrNode;
}
@@ -303,9 +303,9 @@ public AttributeNodeImplementor findOrCreateAttributeNode(Persisten
private AttributeNodeImplementor findOrCreateAttributeNode(PluralPersistentAttribute super J, C, E> attribute) {
verifyMutability();
- final AttributeNodeImplementor node = getNodeForPut( attribute );
+ final var node = getNodeForPut( attribute );
if ( node == null ) {
- final AttributeNodeImplementor newAttrNode = AttributeNodeImpl.create( attribute, isMutable() );
+ final var newAttrNode = AttributeNodeImpl.create( attribute, isMutable() );
attributeNodes.put( attribute, newAttrNode );
return newAttrNode;
}
@@ -316,9 +316,9 @@ private AttributeNodeImplementor findOrCreateAttributeNode(PluralPe
private AttributeNodeImplementor