|
15 | 15 | */
|
16 | 16 | package org.springframework.data.jpa.provider;
|
17 | 17 |
|
18 |
| -import static org.springframework.data.jpa.provider.JpaClassUtils.isEntityManagerOfType; |
19 |
| -import static org.springframework.data.jpa.provider.JpaClassUtils.isMetamodelOfType; |
| 18 | +import static org.springframework.data.jpa.provider.JpaClassUtils.*; |
20 | 19 | import static org.springframework.data.jpa.provider.PersistenceProvider.Constants.*;
|
21 | 20 |
|
22 | 21 | import jakarta.persistence.EntityManager;
|
|
25 | 24 | import jakarta.persistence.metamodel.Metamodel;
|
26 | 25 | import jakarta.persistence.metamodel.SingularAttribute;
|
27 | 26 |
|
28 |
| -import java.util.*; |
| 27 | +import java.util.Collection; |
| 28 | +import java.util.Collections; |
| 29 | +import java.util.List; |
| 30 | +import java.util.NoSuchElementException; |
| 31 | +import java.util.Set; |
29 | 32 |
|
30 | 33 | import org.eclipse.persistence.config.QueryHints;
|
31 | 34 | import org.eclipse.persistence.jpa.JpaQuery;
|
@@ -187,6 +190,8 @@ public String getCommentHintKey() {
|
187 | 190 | }
|
188 | 191 | };
|
189 | 192 |
|
| 193 | + private static final boolean hibernatePresent = ClassUtils.isPresent("org.hibernate.query.TypedParameterValue", |
| 194 | + PersistenceProvider.class.getClassLoader()); |
190 | 195 | private static final Collection<PersistenceProvider> ALL = List.of(HIBERNATE, ECLIPSELINK, GENERIC_JPA);
|
191 | 196 |
|
192 | 197 | static ConcurrentReferenceHashMap<Class<?>, PersistenceProvider> CACHE = new ConcurrentReferenceHashMap<>();
|
@@ -319,13 +324,12 @@ public boolean canExtractQuery() {
|
319 | 324 | */
|
320 | 325 | public static Object condense(Object value) {
|
321 | 326 |
|
322 |
| - ClassLoader classLoader = PersistenceProvider.class.getClassLoader(); |
323 |
| - |
324 |
| - if (ClassUtils.isPresent("org.hibernate.query.TypedParameterValue", classLoader)) { |
| 327 | + if (hibernatePresent) { |
325 | 328 |
|
326 | 329 | try {
|
327 | 330 |
|
328 |
| - Class<?> typeParameterValue = ClassUtils.forName("org.hibernate.query.TypedParameterValue", classLoader); |
| 331 | + Class<?> typeParameterValue = ClassUtils.forName("org.hibernate.query.TypedParameterValue", |
| 332 | + PersistenceProvider.class.getClassLoader()); |
329 | 333 |
|
330 | 334 | if (typeParameterValue.isInstance(value)) {
|
331 | 335 | return null;
|
|
0 commit comments