DATAJPA-1647 - Removes broken caching of ParameterBinder.

The caching was broken because ParameterMetadata used for the key lacked a proper equals and hashCode implementation.
Also it references the EntityManager and itself gets referenced in the ParameterBinder and therefore can't safely be cached.

Signed-off-by: Jens Schauder <jschauder@pivotal.io>
Original pull request: #402.
This commit is contained in:
Jens Schauder
2019-12-19 09:07:51 +01:00
committed by Mark Paluch
parent 26311d5fba
commit 25ebe74915

View File

@@ -16,8 +16,6 @@
package org.springframework.data.jpa.repository.query;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.persistence.EntityManager;
import javax.persistence.Query;
@@ -211,7 +209,6 @@ public class PartTreeJpaQuery extends AbstractJpaQuery {
private final @Nullable CriteriaQuery<?> cachedCriteriaQuery;
private final @Nullable ParameterBinder cachedParameterBinder;
private final PersistenceProvider persistenceProvider;
private final Map<List<ParameterMetadata<?>>, ParameterBinder> binderCache = new ConcurrentHashMap<>();
private final QueryParameterSetter.QueryMetadataCache metadataCache = new QueryParameterSetter.QueryMetadataCache();
QueryPreparer(PersistenceProvider persistenceProvider, boolean recreateQueries) {
@@ -335,8 +332,7 @@ public class PartTreeJpaQuery extends AbstractJpaQuery {
}
private ParameterBinder getBinder(List<ParameterMetadata<?>> expressions) {
return this.binderCache.computeIfAbsent(expressions,
key -> ParameterBinderFactory.createCriteriaBinder(parameters, key));
return ParameterBinderFactory.createCriteriaBinder(parameters, expressions);
}
private Sort getDynamicSort(JpaParametersParameterAccessor accessor) {