committed by
Mark Paluch
parent
8ac6c02a1c
commit
bc9ebb7927
@@ -172,7 +172,7 @@ public class EnversRevisionRepositoryImpl<T, ID, N extends Number & Comparable<N
|
||||
|
||||
AuditQuery baseQuery = createBaseQuery(id);
|
||||
|
||||
List<AuditOrder> orderMapped = (pageable.getSort()instanceof RevisionSort revisionSort)
|
||||
List<AuditOrder> orderMapped = (pageable.getSort() instanceof RevisionSort revisionSort)
|
||||
? List.of(mapRevisionSort(revisionSort))
|
||||
: mapPropertySort(pageable.getSort());
|
||||
|
||||
|
||||
@@ -54,7 +54,6 @@ public class JpaMetamodelMappingContext
|
||||
*/
|
||||
public JpaMetamodelMappingContext(Set<Metamodel> models) {
|
||||
|
||||
Assert.notNull(models, "JPA metamodel must not be null");
|
||||
Assert.notEmpty(models, "JPA metamodel must not be empty");
|
||||
|
||||
this.models = new Metamodels(models);
|
||||
|
||||
@@ -58,7 +58,6 @@ class JpaPersistentEntityImpl<T> extends BasicPersistentEntity<T, JpaPersistentP
|
||||
|
||||
super(information, null);
|
||||
|
||||
Assert.notNull(proxyIdAccessor, "ProxyIdAccessor must not be null");
|
||||
this.proxyIdAccessor = proxyIdAccessor;
|
||||
this.metamodel = metamodel;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ abstract class JpaClassUtils {
|
||||
*/
|
||||
public static boolean isEntityManagerOfType(EntityManager em, String type) {
|
||||
|
||||
EntityManager entityManagerToUse = em.getDelegate()instanceof EntityManager delegate //
|
||||
EntityManager entityManagerToUse = em.getDelegate() instanceof EntityManager delegate //
|
||||
? delegate //
|
||||
: em;
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ public enum PersistenceProvider implements QueryExtractor, ProxyIdAccessor, Quer
|
||||
|
||||
private static final Collection<PersistenceProvider> ALL = List.of(HIBERNATE, ECLIPSELINK, GENERIC_JPA);
|
||||
|
||||
static ConcurrentReferenceHashMap<Class<?>, PersistenceProvider> CACHE = new ConcurrentReferenceHashMap<>();
|
||||
private static final ConcurrentReferenceHashMap<Class<?>, PersistenceProvider> CACHE = new ConcurrentReferenceHashMap<>();
|
||||
private final Iterable<String> entityManagerClassNames;
|
||||
private final Iterable<String> metamodelClassNames;
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ public class JSqlParserQueryEnhancer implements QueryEnhancer {
|
||||
|
||||
Select selectStatement = parseSelectStatement(queryString);
|
||||
|
||||
if (selectStatement instanceof SetOperationList setOperationList) {
|
||||
if (selectStatement instanceof SetOperationList setOperationList) {
|
||||
return applySortingToSetOperationList(setOperationList, sort);
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ public class JSqlParserQueryEnhancer implements QueryEnhancer {
|
||||
}
|
||||
|
||||
Select selectStatement = (Select) statement;
|
||||
if (selectStatement instanceof PlainSelect selectBody) {
|
||||
if (selectStatement instanceof PlainSelect selectBody) {
|
||||
return getJoinAliases(selectBody);
|
||||
}
|
||||
|
||||
@@ -315,7 +315,7 @@ public class JSqlParserQueryEnhancer implements QueryEnhancer {
|
||||
* ValuesStatement has no alias
|
||||
* SetOperation can have multiple alias for each operation item
|
||||
*/
|
||||
if (!(selectStatement instanceof PlainSelect selectBody)) {
|
||||
if (!(selectStatement instanceof PlainSelect selectBody)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ public class JSqlParserQueryEnhancer implements QueryEnhancer {
|
||||
/*
|
||||
We only support count queries for {@link PlainSelect}.
|
||||
*/
|
||||
if (!(selectStatement instanceof PlainSelect selectBody)) {
|
||||
if (!(selectStatement instanceof PlainSelect selectBody)) {
|
||||
return this.query.getQueryString();
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ public class JSqlParserQueryEnhancer implements QueryEnhancer {
|
||||
|
||||
Select selectBody = selectStatement;
|
||||
|
||||
if (selectStatement instanceof SetOperationList setOperationList) {
|
||||
if (selectStatement instanceof SetOperationList setOperationList) {
|
||||
|
||||
// using the first one since for setoperations the projection has to be the same
|
||||
selectBody = setOperationList.getSelects().get(0);
|
||||
|
||||
@@ -186,7 +186,7 @@ abstract class QueryParameterSetterFactory {
|
||||
@Override
|
||||
public QueryParameterSetter create(ParameterBinding binding, DeclaredQuery declaredQuery) {
|
||||
|
||||
if (!(binding.getOrigin()instanceof ParameterBinding.Expression e)) {
|
||||
if (!(binding.getOrigin() instanceof ParameterBinding.Expression e)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ abstract class QueryParameterSetterFactory {
|
||||
Assert.notNull(binding, "Binding must not be null");
|
||||
|
||||
JpaParameter parameter;
|
||||
if (!(binding.getOrigin()instanceof MethodInvocationArgument mia)) {
|
||||
if (!(binding.getOrigin() instanceof MethodInvocationArgument mia)) {
|
||||
return QueryParameterSetter.NOOP;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.springframework.context.ApplicationContext;
|
||||
class JpaMetamodelCacheCleanup implements DisposableBean {
|
||||
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
public void destroy() {
|
||||
JpaMetamodel.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import static org.springframework.data.jpa.provider.PersistenceProvider.Constant
|
||||
import jakarta.persistence.EntityManager;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.assertj.core.api.Assumptions;
|
||||
import org.hibernate.Version;
|
||||
@@ -32,6 +33,7 @@ import org.mockito.Mockito;
|
||||
import org.springframework.asm.ClassWriter;
|
||||
import org.springframework.asm.Opcodes;
|
||||
import org.springframework.instrument.classloading.ShadowingClassLoader;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
@@ -48,7 +50,8 @@ class PersistenceProviderUnitTests {
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
|
||||
PersistenceProvider.CACHE.clear();
|
||||
Map<?, ?> cache = (Map<?, ?>) ReflectionTestUtils.getField(PersistenceProvider.class, "CACHE");
|
||||
cache.clear();
|
||||
|
||||
this.shadowingClassLoader = new ShadowingClassLoader(getClass().getClassLoader());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user