From ce062072bfe3a99da5197019face7ff771dcc16d Mon Sep 17 00:00:00 2001 From: Christoph Strobl Date: Tue, 19 Nov 2024 15:52:10 +0100 Subject: [PATCH] Deprecate `JpaEntityGraph.isAdHocEntityGraph()` method. An EntityGraph without attributes is valid. Therefore it is not possible to determine if a given JpaEntityGraph is a dynamic one just by looking at the attributes alone. Original pull request: #3684 See #3682 --- .../data/jpa/repository/query/JpaEntityGraph.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpaEntityGraph.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpaEntityGraph.java index d1a6b4593..32d86e503 100644 --- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpaEntityGraph.java +++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpaEntityGraph.java @@ -15,7 +15,6 @@ */ package org.springframework.data.jpa.repository.query; -import java.util.Arrays; import java.util.List; import org.springframework.data.jpa.repository.EntityGraph; @@ -29,12 +28,11 @@ import org.springframework.util.StringUtils; * * @author Thomas Darimont * @author Mark Paluch + * @author Christoph Strobl * @since 1.6 */ public class JpaEntityGraph { - private static String[] EMPTY_ATTRIBUTE_PATHS = {}; - private final String name; private final EntityGraphType type; private final List attributePaths; @@ -46,8 +44,8 @@ public class JpaEntityGraph { * @param nameFallback must not be {@literal null} or empty. */ public JpaEntityGraph(EntityGraph entityGraph, String nameFallback) { - this(StringUtils.hasText(entityGraph.value()) ? entityGraph.value() : nameFallback, entityGraph.type(), entityGraph - .attributePaths()); + this(StringUtils.hasText(entityGraph.value()) ? entityGraph.value() : nameFallback, entityGraph.type(), + entityGraph.attributePaths()); } /** @@ -65,7 +63,7 @@ public class JpaEntityGraph { this.name = name; this.type = type; - this.attributePaths = Arrays.asList(attributePaths == null ? EMPTY_ATTRIBUTE_PATHS : attributePaths); + this.attributePaths = attributePaths != null ? List.of(attributePaths) : List.of(); } /** @@ -99,9 +97,12 @@ public class JpaEntityGraph { /** * Return {@literal true} if this {@link JpaEntityGraph} needs to be generated on-the-fly. * - * @return + * @return {@literal true} if {@link #attributePaths} is not empty. * @since 1.9 + * @deprecated since 3.4.1 as the used evaluation does not represent whether a {@link JpaEntityGraph} is dynamic or + * not. */ + @Deprecated(since = "3.4.1", forRemoval = true) public boolean isAdHocEntityGraph() { return !attributePaths.isEmpty(); }