diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/provider/PersistenceProvider.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/provider/PersistenceProvider.java index 379e30b55..537b8023b 100644 --- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/provider/PersistenceProvider.java +++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/provider/PersistenceProvider.java @@ -55,7 +55,7 @@ import org.springframework.util.ConcurrentReferenceHashMap; * @author Greg Turnquist * @author Yuriy Tsarkov */ -public enum PersistenceProvider implements QueryExtractor, ProxyIdAccessor, QueryComment, PresenceDetector { +public enum PersistenceProvider implements QueryExtractor, ProxyIdAccessor, QueryComment { /** * Hibernate persistence provider. @@ -204,7 +204,7 @@ public enum PersistenceProvider implements QueryExtractor, ProxyIdAccessor, Quer private final Iterable entityManagerClassNames; private final Iterable metamodelClassNames; - private boolean present; + private final boolean present; /** * Creates a new {@link PersistenceProvider}. @@ -218,12 +218,16 @@ public enum PersistenceProvider implements QueryExtractor, ProxyIdAccessor, Quer this.entityManagerClassNames = entityManagerClassNames; this.metamodelClassNames = metamodelClassNames; - this.present = false; - entityManagerClassNames.forEach(entityManagerClassName -> { + boolean present = false; + for (String entityManagerClassName : entityManagerClassNames) { + if (ClassUtils.isPresent(entityManagerClassName, PersistenceProvider.class.getClassLoader())) { - this.present = true; + present = true; + break; } - }); + } + + this.present = present; } /** @@ -340,7 +344,6 @@ public enum PersistenceProvider implements QueryExtractor, ProxyIdAccessor, Quer : value; } - @Override public boolean isPresent() { return this.present; } diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/provider/PresenceDetector.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/provider/PresenceDetector.java deleted file mode 100644 index e6bd19e70..000000000 --- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/provider/PresenceDetector.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - - */ -package org.springframework.data.jpa.provider; - -/** - * Define operations needed to detect the presence of a given JPA provider. - * - * @author Greg Turnquist - * @since 3.2 - */ -interface PresenceDetector { - boolean isPresent(); -} diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/EqlQueryRenderer.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/EqlQueryRenderer.java index 91ede2389..a1efef404 100644 --- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/EqlQueryRenderer.java +++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/EqlQueryRenderer.java @@ -26,6 +26,7 @@ import java.util.List; * @author Greg Turnquist * @since 3.2 */ +@SuppressWarnings({ "ConstantConditions", "DuplicatedCode" }) class EqlQueryRenderer extends EqlBaseVisitor> { @Override diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/HqlQueryRenderer.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/HqlQueryRenderer.java index 3f5aa00df..ca2e934b8 100644 --- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/HqlQueryRenderer.java +++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/HqlQueryRenderer.java @@ -26,6 +26,7 @@ import java.util.List; * @author Greg Turnquist * @since 3.1 */ +@SuppressWarnings({ "ConstantConditions", "DuplicatedCode" }) class HqlQueryRenderer extends HqlBaseVisitor> { @Override diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpqlQueryRenderer.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpqlQueryRenderer.java index 7ff5a6f39..bac7e2400 100644 --- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpqlQueryRenderer.java +++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpqlQueryRenderer.java @@ -26,6 +26,7 @@ import java.util.List; * @author Greg Turnquist * @since 3.1 */ +@SuppressWarnings({ "ConstantConditions", "DuplicatedCode" }) class JpqlQueryRenderer extends JpqlBaseVisitor> { @Override